Thursday, February 25, 2021

Including config.h in every file in Visual Studio

Rather than explicitly including a header file in every source file, I like to use gcc's -include flag to add a config.h file, a file holding global configuration options that every source file may or may not be using. For a long time I didn't think that Visual Studio had a similar option, but I finally dug it out here:

https://docs.microsoft.com/en-us/cpp/build/reference/fi-name-forced-include-file?view=msvc-160

The flag is /FI and you can set it in Visual Studio by right-clicking the project, selecting Properties, then C/C++, Advanced, and setting the "Forced Include File" property. Convenient!


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.