Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
Qt Creator 3.2.0-beta1, Qt Creator 3.4.0-beta1
-
None
Description
The preprocessor does not expand arguments of function-like macros before substitution. Instead, it seems to expand the result of a function-like macro only after substitution.
#define BEFORE AFTER #define SHOW(a, b) show_##a show_##b #define TEST(a) SHOW(test_##a, a) TEST(BEFORE)
- QtCreator result: show_test_BEFORE show_BEFORE
- g++ -E result: show_test_BEFORE show_AFTER
I think the rule is that macro arguments are expanded unless they're used with stringification or token pasting. See https://gcc.gnu.org/onlinedocs/cpp/Argument-Prescan.html .
This causes failures with most uses of the boost preprocessor library and is likely the root cause behind QTCREATORBUG-11243.
Attachments
Issue Links
- relates to
-
QTCREATORBUG-11243 Regression: macro expansion in editor not working properly, says "expected a declaration"
- Closed
-
QTCREATORBUG-13219 Preprocessor should expand macros that are passed to function-like macros in define
- Closed