einpoklum
einpoklum

Reputation: 132118

Inject a preprocessor definition into the Eclipse parser for a certain file type?

I'm using Eclipse CDT (actually, nVIDIA's nSight, but the same goes for both) to edit some source files. Now, some of these are meant for use both with nvcc and with regular host-side compilers, and have some instances of:

#ifdef __CUDACC__
something
#else
some other thing
#endif

I want to get the __CUDACC__ part when the preprocessor is reaching a file while parsing a .cuh or .cu, but not when reaching it while parsing a .h or .cpp (or .c). Now, I know I can inject a preprocessor define through the project settings (using the "built-in compiler" command line), but I was wondering whether it's possible to make that conditional on the extension of the file being parsed originally (i.e. the file being edited in the IDE).

Upvotes: 1

Views: 209

Answers (1)

HighCommander4
HighCommander4

Reputation: 52839

How are you configuring the project's include paths and defined macros?

If you use the Build Output Parser, can you arrange for the build system to include -D __CUDACC__ in the compiler commands for .cu files, but not for the compiler commands for .cpp files?

CDT allows for each file in the project to have its own settings, and the Build Output Parser will assign each file that has a compilation command in the build output its own settings based on the flags that appear in the command, so things should just work.

Upvotes: 1

Related Questions