15

Is there a #define compiler (nvcc) macro of CUDA which I can use? (Like _WIN32 for Windows and so on.)

I need this for header code that will be common between nvcc and VC++ compilers. I know I can go ahead and define my own and pass it as an argument to the nvcc compiler (-D), but it would be great if there is one already defined.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292

2 Answers2

14
__CUDACC__

I don't think it will be that trivial. Check the following thread

http://forums.nvidia.com/index.php?showtopic=32369&st=0&p=179913&#entry179913

basszero
  • 29,624
  • 9
  • 57
  • 79
  • @AlejandroSazo: That is what it is supposed to print - it identifies whether code is being compiled through nvcc or another compiler. – talonmies Jun 15 '13 at 09:22
4

I know it has been long time now, but you might also find __CUDA_ARCH__ useful.

talonmies
  • 70,661
  • 34
  • 192
  • 269