My question is similar to this question, if you do not have too much time to read my question, you can read that shorter one.
My project used a config file
targetName=module01
The config file is parsed by a .exe and compile commands are generated, like this
cl.exe /D "MODULE_NAME=module01" /D BUILDING_module01
So the targetName is related to two pre-processor macros.
My source file looks like
#ifdef BUILDING_module01
// do something
#endif
So bascially the //do something part will always get executed if targetName in soucre file match with that in config file. The problem is that I am frequently changing the targetName in config file, and I do not want to change the source file that frequently.
I would like something like, by using pre-processor macros
#ifdef BUILDING_ ## MODULE_NAME
// do something
#endif
I used tricks in here. But the macro substitution will always make BUILDING_ ## MODULE_NAME equal to 1, so the compiler complains
warning C4067: unexpected tokens following preprocessor directive - expected a newline
Is there any way I can achieve this?