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.
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
Demo on Godbolt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With