Friday, April 11, 2014

Add a Macro property in a Visual Studio Project and use it in the sorce code

1. In Property Manager of your project,  property page -> User Macros -> Add Macro

VERSION with value of "1.0"














2.  In property sheet, C/C++ -> Preprocessor -> Preprocessor Definitions, define a function macro.











PROJECTVERSION=VERSION(\"$(VERSION)\")

3.  In your sorce file, after all includes add following code snippet.


#ifdef  UNICODE  
#define VERSION(text) L##text
#else
#define VERSION(text) text
#endif



4. Then in your source code you can use "PROJECTVERSION" where ever you want to access the value of the defined macro.