c++ - [Bug report] Macros fail to expand
- Daniel James (19/19) Aug 12 2004 Under certain circumstances macros don't expand correctly.
Under certain circumstances macros don't expand correctly. #define FOO(arg) arg #define CALL(x, y) CALL2(x(y)) #define CALL2(result) result CALL(FOO, 1) This should expand to '1', but it expands to FOO(1). The same for: #define FOO(arg) arg #define CALL_ALT(x, y) CALL_ALT_2(x y) #define CALL_ALT_2(x) x CALL_ALT(FOO, (1)) I've attached some test cases from the wave preprocessor test suite which test this kind of thing in more detail. Wave is a highly compliant preprocessor implementation which is available from: The //E lines indicate the expected result of the previous line's macro call. Although, I think that very few preprocessors will get test13/14/15.cpp right, so they're pretty pathological cases. Maybe only wave and gcc's preprocessor will get them right. Daniel
Aug 12 2004