Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to define configuration dependent properties in VS C++ project?

I’m really new to C++ and Visual Studio, I know there are ifdef and ifndef to do the conditional compilation.
But my boss ask me to create 2 different configurations (similar to debug and release) to automate this. For example:

#if $(some_configuration_dependent_flag)
  // I can do something specific for only config1
#endif

I’ve already checked the configuration manager, but the dialog is only used to enable/disable the projects in the solution. Where and how to define the variable some_configuration_dependent_flag mentioned above?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Visual Studio allows per config pre-processor definitions.

Use menu Project/Properties (on right click + Properties on the project) to open the Property Page dialog

Then in C/C++ / Preprocessor, you find Preprocessor Definitions. You select the configuration you want to change, and can add or modify any definition.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading