【问题标题】:Cuda error C2054: expected '(' to follow '__device__'Cuda 错误 C2054:预期 '(' 跟随 '__device__'
【发布时间】:2011-12-25 18:15:58
【问题描述】:

文件以 .cu 扩展名命名。它在抱怨我的设备功能定义...您还需要什么其他信息?

d.cu(96): error C2054: expected '(' to follow '__device__'
d.cu(96): error C2085: 'distance' : not in formal parameter list
d.cu(96): error C2143: syntax error : missing ';' before '{'

第 96 行的实际函数:(Float2d 是一个结构)

__device__ 
float distance(Float2d A, Float2d B){
return sqrtf( (A.x-B.x)*(A.x-B.x) + (A.y-B.y)*(A.y-B.y) );
}

【问题讨论】:

  • 是的,文件属性里设置了cuda/c++编译的文件(列在source files下)
  • 你认为这听起来像是没有涉及 nvcc?
  • 这确实是我的猜测。但是很高兴您已经解决了它。

标签: c visual-studio-2010 cuda


【解决方案1】:

发现问题:出于某种原因(不久前)我将.cu 文件包含在.c 文件中。不知道为什么/怎么可能我喝醉了。所以这是一个 ID:107 错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-18
    • 2015-03-15
    • 1970-01-01
    • 1970-01-01
    • 2011-07-14
    • 2015-12-10
    • 2020-01-31
    • 2018-09-15
    相关资源
    最近更新 更多