Hello,
I’m using the Eclipse CDT for NVIDIA CUDA development. It’s pretty nice. However, I’d like to disable some C++ syntax errors as there is a handful of CUDA keywords that the Eclipse parser doesn’t like.
Specifically, some of the keywords that makes eclipse barf are
extern “C”
global
device
shared
Here are some screenshots to illustrate:
The global keyword along with the extern “C” stuff throws the Eclipse parser off, see how the entire function is yellowed, and I lose autocompletion in the affected function. This is of course legal CUDA code.
Here I’ve commented out the extern “C” line. The Eclipse parser accepts the function, and autocompletion works.
Just for fun, I’ve disabled the global keyword and the function now appears nice and clean to Eclipse.
So, what to do? On the eclipse.tools.cdt mailing list there was some info about the built in Eclipse C Development Tools parser. If you do this at the top of your .cu file, it fixes things:
#ifdef __CDT_PARSER__
#define __global__
#define __device__
#define __shared__
#endif
… and Eclipse starts playing nicer. What it does is that when the Eclipse parser is running, CDT_PARSER is defined, and this causes the Eclipse parser to define global and friends to nothing, and they stop getting in the way. However, nvcc doesn’t define CDT_PARSER and things compile normally.
Hope this helps someone!