How to specify C/C++ preprocessor directives on visual studio?

Hello:

I’m trying to use some preprocessor directives on visual studio, but it looks like visual studio is not getting them…
So I have, for example

#if TESTING == 1
void foo();

void foo(){
  printf("bar");
}
#endif

int main(){
  foo();

  return 0;
}

Then on “Project > Properties > CUDA C/C++ > Host > Preprocessor Definitios” I specify “TESTING=1”.
I also have activated the “Use Host Preprocessor Definitions” with “Yes” value.

So, I go to “Project > Properties > CUDA C/C++ > Command Line” and I can see the “-DTESTING=1” there.

But when I try to compile, the compilation fails as “identifier foo is undefined”.

I tried to put the “-DTESTING=1” directly under “Additional options” but didn’t work either.

Does anyone knows what’s wrong? If I do the same with plain C it’s working as expected…

Thanks.

Ok, I just found the thing and it’s a bit weird.
If I compile while standing on the source file that has the main() function, it gets the preprocessor; if I do the same while any other source is showing, it does not work.

So I only have to ensure to stay on the “right” source file while compiling…

Hope this can help anyone that have simillar issues.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.