I have a code in c that contains numerous compilation switches. Some are simple like:
#if ENABLE
// source code
....
....
#endif
others are more complex like:
#if (CONFIG_SEL == CONF_A || CONFIG_SEL == CONF_C)
#define LOW_BAND 0
#define HIGH_BAND 1
#endif
#if CONFIG_SEL == CONF_A
#if UNIT_MODEL == UNIT_A
#if MODEL_SUBTYPE == SUBTYPE_A
#include "Config_suba.h"
#elif MODEL_SUBTYPE == SUBTYPE_B
#include "Config_subb.h"
#endif
#elif UNIT_MODEL == UNIT_B
#include "Config_unitb.h"
#elif UNIT_MODEL == UNIT_C
#include "Config_unitc.h"
#else
#include "Config_defaultunit.h"
#endif
#elif CONFIG_SEL == CONF_B
#if X_Y_BAND == Y_BAND
#include "config_xband.h"
#else
#include "config_yband.h"
#endif
#elif CONFIG_SEL == C
#include "Config_c.h"
#elif CONFIG_SEL == D
#include "Config_d.h"
#endif
I was asked to create new .c and .h file where all those parts of code that are not compiled, do not appear in the new code.
Before writing some code in Python which deletes uncompiled switches, I wanted to ask if you knew of a tool that can already do this operation. I tried searching but without success.
Erasing by hand is not an option because this operation must be done on very many projects
Thank you