given the following code:
void doSomething(int one, int two, int three)
{
//something here
}
#define ONE 1,2,3
#define TWO(arg) doSomething(arg);
#define THREE(arg) TWO(arg)
void doSomethingElse()
{
TWO(ONE)
THREE(ONE)
}
visual studio 2010 has the following preprocessor output (omitting some blank lines):
void doSomething(int one, int two, int three)
{
}
void doSomethingElse()
{
doSomething(1,2,3);
doSomething(1,2,3);
}
while gcc 4.2 gives the following:
void doSomething(int one, int two, int three)
{
}
void doSomethingElse()
{
doSomething(1,2,3);
myFile.cpp:17:13: error: macro "TWO" passed 3 arguments, but takes just 1
TWO
}
I'm not sure which is standard, but I'd like it to work like visual studio is working. Is there a way to refactor the code so that it works this way in both compilers?