Hope you’ve heard of conditional compilation. Conditional compilation simply means what it says, i.e. compile only when a certain condition is true and it’s only meant for the compiler hence it should only take place during compilation.
We do conditional compilation with help of preprocessor commands. For eg:
[sourcecode language=’cpp’]void WhoIsNibu()
printf( “Nibu is an MVP, Mwhahahaha, Nibu loves Jesus” );
printf( “Nibu is still an MVP hehe ;), He loves Jesus” );
Well now the first printf will only be “compiled” if you define NIBU_IS_A_VERY_GOOD_MVP else the second one will be “compiled”.
Well this was something about conditional compilation, now about including a resource based on a condition. This is mainly for those who are using VC resource editor to include a resource for others you can simply follow normal conditional compilation to decide whether to include or not to include a resource…
In VC resource editor right click on a resource for eg: a menu resource and select properties, now you will find a text field called “Condition”
See the controls encircled in red.
I’ve entered _DEBUG here, so this menu will only be compiled into the exe when _DEBUG is defined else it won’t be.
Very easy isn’t it. Recently someone asked this in a forum hence thought of posting it here. This is in VC6 but I am sure there is a similar (and better) option in later versions of visual studio too.