CUDA:__device__和__global__错误:在"无符号"/"void"之前预期的构造函数、析构函数或类型转换"
CUDA: __device__ and __global__ error: expected constructor, destructor, or type conversion before "unsigned"/"void""
所以我的问题是:我在mac os x mountain lion上使用Nvidia的insight应用程序来编写CUDA应用程序:源代码是.h/.cu/.cpp组合。
我有一个HelloCUDA.h头文件,声明如下:
//yep, both taken from examples.
__device__ unsigned int bitreverse2(unsigned int number);
__global__ void bitreverse(void *data);
和我有一个HelloCUDA。定义这些方法的Cu文件:
__device__ unsigned int bitreverse3(unsigned int number) {
//definition
return number;
}
__global__ void bitreverse4(void *data) {
//another definition...
bitreverse3(idata[threadIdx.x]);
}
它工作了,直到我使用eclipse的(insight)新类向导添加了一个新的c++类文件(.h/.cpp)。现在,当我试图构建这个东西:
../src/HelloCUDA.h:21: error: expected constructor, destructor, or type conversion before ‘unsigned’
../src/HelloCUDA.h:23: error: expected constructor, destructor, or type conversion before ‘void’
我检查了项目设置,我认为没有任何变化。
那么,发生了什么?有人能帮我解决这个问题吗?
以上的解决方案对我都没有帮助。只是在文件的顶部导入:
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
解决它。(我在VS Studio2019下)
您可能使用"CUDA C Bitreverse Application"模板创建了一个新的CPP文件。该模板是为CUDA C文件。只需删除文件内容并添加您的c++代码即可。
相关文章:
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- new[] / delete[] 并在C++中抛出构造函数/析构函数
- 创建/向容器添加对象时如何使用构造函数/析构函数
- LNK2019构造函数/析构函数使用 C++ Dll
- 有人可以解释一下这里发生了什么(类和构造函数/析构函数)吗?
- 带智能ptr的Pimpl-为什么需要构造函数/析构函数
- 需要构造函数/析构函数/类型转换错误
- Boost共享指针构造函数/析构函数
- 通过值或引用调用时未调用构造函数/析构函数.不管怎样
- C++构造函数析构函数中的奇怪行为
- 构造函数/析构函数链接错误
- 在模板化函数中调用具有特征的显式构造函数/析构函数
- c++构造函数/析构函数
- 为什么赋值的成本不能保证小于构造函数-析构函数对
- 重写默认构造函数/析构函数而不实现它们
- 使用自定义分配器调用对象构造函数/析构函数
- 涉及类和结构的构造函数/析构函数
- 在抽象构造函数/析构函数中调用纯虚拟函数安全吗
- 如果在没有限定的情况下从构造函数/析构函数调用虚拟函数,则是否会发生虚拟调度
- C++基于堆栈的构造函数/析构函数无法按预期工作