According to https://llvm.org/docs/CompileCudaWithLLVM.html#detecting-clang-vs-nvcc-from-code if I compile a CUDA file then __CUDACC__ should be defined. I have this program as 'clang_cuda.cu':
#if !defined(__clang__)
#error Clang is not defined
#elif !defined(__CUDACC__)
#error __CUDACC__ is not defined
#elif !defined(__CUDA__)
#error __CUDA__ is not defined
#endif
int main(void) {
return 0;
}
which I compile with clang-9.0 targeting gcc on Windows with:
clang++ -c -m64 -O0 -fno-inline -Wall -g -pthread -target x86_64-pc-windows-gnu -nocudainc -nocudalib -x cuda -o clang_cuda.obj clang_cuda.cu
the program outputs the preprocessor error: __CUDACC__ is not defined
Why is this ?