You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
token pasting with "defined" works with gcc (cpp) but not simplecpp #218
I am using a third-party peripheral library from the manufacturer of the microprocessor that we are using, and it contains a token-pasting macro identical to the one labeled "THIS ONE" below:
#define __FOO__ 1
#define IS_DEFINED(name) (defined(__ ## name ## __)) // <--THIS ONE
#warning Before IS_DEFINED(FOO)
#if IS_DEFINED(FOO)
#warning Inside IS_DEFINED(FOO)
#endif
#warning After IS_DEFINED(FOO)
When I run cpp (Ubuntu v9.3.0) the IS_DEFINED() macro works as intended:
$ ./simplecpp test_token_pasting.cpp
test_token_pasting.cpp:5: #warning: #warning Before IS_DEFINED(FOO)
test_token_pasting.cpp:11: #warning: #warning After IS_DEFINED(FOO)
...the IS_DEFINED() macro doesn't appear to work. Per @danmar, the specs say this macro results in undefined behavior, but it does seem to work with this version of gcc.
Activity
firewave commentedon Jul 3, 2025
Looks like a duplicate of #75.
Somehow it only prints a single line.