简体   繁体   中英

How to use Visual Studio Macros at compile time in a c++ project

I would like my code to behave differently at compile time by using the configuration parameter.

Something like the sample code below. I need my project to include different headers in each configuration.

#if $(Configuration) == "my_csutom_config"
#include "my_custom_header.h"
#elif
#include "std_header.h"
#endif

Turns out it cannot be done as I wanted but through an indirect step:

In project Properties-> configuration Properties -> C/C++ -> Preprocessor I can simply define a preprocessor variable for each configuration and then use that preprocessor variable as I wanted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM