CUDA上的“错误包含cudart标头”错误

“incorrect inclusion of a cudart header” error on CUDA

为了进行数学运算,我添加了头文件

1
2
#include <math_functions.h>
#include <device_functions.h>

但是当我编译它时,它开始出现以下错误。 我该怎么办?

ps.:CUDA 5.0,VS2010

NVIDIA GPU Computing Toolkit\\CUDA\\v5.0\\include\\crt/func_macro.h(50):
fatal error C1189: #error : -- incorrect inclusion of a cudart header
file


您只需要用#define和#undef包裹#include" math_functions.h",如下所示:

1
2
3
#define __CUDA_INTERNAL_COMPILATION__
#include"math_functions.h"
#undef __CUDA_INTERNAL_COMPILATION__

并且似乎math_functions.h可能未包含在.cpp文件中。