Set preprocessor definitions from file content in Visual C++
问题 I have a file in my project which contains the project version number. I have to make the content of this file available as a preprocessor definition in my code. What I need is to somehow pass the value from the file to the compiler as a /D parameter. I tried to add the preprocessor definition VERSION=$(Version) and set the Version environment variable in a prebuild step, but I did not find a way to do the latter, so I got stuck. 回答1: As a workaround, a pre-build step could be created which