That's right I want to supply a path as preprocessor define (properties->configuration->c/c ->preprocessor)
MY_PATH=c:\$(WindowsSdkDir)\um
But this hits me upon use with
E1696 cannot open source file "C:\asdf\u0000m\xyz.h"
E0992 command-line error: invalid macro definition: MY_PATH=c:\asdf\um
Because visual studio seemingly sees \u as a unicode escape. However, there is no way to escape the backslash, so now I cant specify any path that contains a directory starting on u. I also cant switch to / as a path separator because I pull in environment variables that use .
What to do?
I am on latest Windows 10 with latest SDK and Visual Studio 2019.
CodePudding user response:
Use four backslashes: -DMY_PATH=\"C:\\\\asdf\\\\u0000m\\\\xyz.h\"
https://godbolt.org/z/9Yn4csjv1
CodePudding user response:
You should use raw string literals for anything that requires escaping instead
char const * ddd = R"(C:\asdf\u0000m\xyz.h)";
No more escaping required and the result is much more readable. So in this case on the command line you'll use
-DMY_PATH=R\"\(C:\\asdf\\u0000m\\xyz.h\)\"
because you only need to escape for the shell and not the C source code