The following C++ code compiles and works as the programmer intended on GCC (4.0.4)
#define FOO(x,y,z) ((x)*(y)*(z))
#define BAR(x) FOO(x,1)
#define BAZ 3,7
int main()
{
return BAR(BAZ); /* interpreted as return ((3)*(7)*(1)); */
}
However, the macros cause an error on Microsoft Visual C++ Express 2010:
main.cpp(7): warning C4003: not enough actual parameters for macro 'FOO'
main.cpp(7): error C2059: syntax error : ')'
The issue seems to be that the Microsoft compiler, while handling the BAR macro internally, does not expand the BAZ macro to parameters that could be used as two separate parameters to macro FOO.
According to the standard, which compiler handles the situation correctly?