I have the following preprocessed macro defined under C/C++ -> Command Line -> Additional Options:
/D NV_WORKING_DIRECTORY="C:/foo"
An image from the project settings:
I have the following code:
std::string path = NV_WORKING_DIRECTORY;
When I compile I get this error:
‘C’: undeclared identifier.
Weirdly, with certain strings the code works. For example if I do /D NV_WORKING_DIRECTORY="foo" everything is good. But "garbage" for some reason gives the same error.
Hardcoding#define NV_WORKING_DIRECTORY "C:/foo/" makes the code above work, but because I need a global macro that is not an option.
Is there something I am doing wrong here? This is a brand new project, and I have not messed around with anything yet.
>Solution :
When you use /D in the C/C++ -> Command Line -> Additional Options, the value is expected to be wrapped in a string.
E.g. the following means the value of XXX will be YYY:
/D XXX="YYY"
Therefore if you need the value of the preprocessor definition to contain the quotes, you need to add and escape them:
/D NV_WORKING_DIRECTORY="\"C:/foo/\""
Alternatively you can add the NV_WORKING_DIRECTORY defintion under C/C++ -> Preprocessor Definitions.
There you can simply put the string value that you need:
NV_WORKING_DIRECTORY="C:/foo/"
