I have a program consisting out of different modules. The modules are interconnected via function calls. E.g. State Init calls the init function of every module. It shall be possible to disable modules (exclude from compilation). The easiest way would be using preprocessor defines. But this generates massive amount of code:
#IF MODULE_XXX_COMPILE
ret = module_func(...);
#ELSE
ret = 0;
#ENDIF
I would like to get a macro like this:
ret = MOD_COMPILE_CALL(module_func(...));
So the macro checks if the define is 1 if yes it executes the functions else it skips the execution and returns 0.
The problem is that my compiler is telling me that its not possible to use #IF
in a macro. Is there a way around it?
#define MOD_COMPILE_CALL(x)
to expand to eitherx
or0
depending onMODULE_XXX_COMPILE
.