Reputation: 173
How can I use an environment variable, say %WINDIR% in VS? I tried in Properties > Preprocessor > Definitions > I added: ENV_VAR="($Windir)"
in my .cpp:
std::string s = ENV_VAR
but when executed it prints:
C:windows
How do I fix this?
Upvotes: 3
Views: 722
Reputation: 173
Found the solution:
How to get a Visual Studio Macro Value into a pre processor directive?
in my example I should add:
ENV_VAR=R"?($(WINDIR))?"
Upvotes: 3