I have a requirement something like
void doSomeThing(int x)
{
.....
}
void fun()
{
#ifdef XXXX_1_YYYY
doSomeThing(XXXX_1_YYYY);
#endif //XXXX_1_YYYY
#ifdef XXXX_2_YYYY
doSomeThing(XXXX_2_YYYY);
#endif //XXXX_2_YYYY
#ifdef XXXX_3_YYYY
doSomeThing(XXXX_3_YYYY);
#endif //XXXX_3_YYYY
#ifdef XXXX_4_YYYY
doSomeThing(XXXX_4_YYYY);
#endif //XXXX_4_YYYY
....
upto XXXX_20_YYYY
}
Is there anyway i can reduce the typing of this upto 20 using some macro expansion technique or any other solution?
MACRO definition can be something like this
#define XXXX_1_YYYY 10
#define XXXX_2_YYYY 20
#define XXXX_3_YYYY 30
#define XXXX_4_YYYY 40
...
#define XXXX_20_YYYY 200
Each of the #ifdef
are not mutually exclusive.
The code is in c++