#define X typedef int unused; Y
#define Y
X
// comment
#include <stddef.h>
chibicc -c a.c:
a.c:5: #include <stddef.h>
^ variable name omitted
chibicc -E a.c:
typedef int unused; #include <stddef.h>
chibicc is eliminating the newlines and comments after the line X and concatenating the #include line onto the end of the macro expansion. It doesn't matter how many newlines or comments you add after X; the preprocessor swallows them all and never processes the #include. This has something to do with the empty Y at the end of #define X because it works fine without it.
The only workaround I've found is to put some other declaration (another unused typedef) between the X expansion and the #include. And I can't put this workaround under #ifdef __chibicc__ either because the #ifdef gets concatenated onto the macro expansion instead :)
In
a.c
:chibicc -c a.c
:chibicc -E a.c
:chibicc is eliminating the newlines and comments after the line
X
and concatenating the#include
line onto the end of the macro expansion. It doesn't matter how many newlines or comments you add afterX
; the preprocessor swallows them all and never processes the#include
. This has something to do with the emptyY
at the end of#define X
because it works fine without it.The only workaround I've found is to put some other declaration (another unused typedef) between the X expansion and the
#include
. And I can't put this workaround under#ifdef __chibicc__
either because the#ifdef
gets concatenated onto the macro expansion instead :)