-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Token spacing in preprocessor #24
Comments
I hate space, stringize, glue and back slash! |
I doubt if both are correct, it is just that the preprocessor's dump function can't generate pretty readable code. |
The preprocessor must handle macro expansion carefully in order to get right column number etc. It's tricky. That explains why early C compilers don't contain column number in diagnostic messages. |
I think they are not identical token stream. |
That right way of checking if the compiler handles column(or space) correctly is try below snippet:
str should be initiated by string literal "++ -- ++ ===" which are both generated by wgtcc and gcc. |
It's just one of numerous test cases. |
The -E option is just for dumping the preprocessed code for programmer. wgtcc 's dump function is so simple that the dumped code can't be compiled to get the same by compiling the .c file. But it can be fixed by simply inserting a space between two tokens. |
Actually, |
So it is the dump function that should be fixed. |
The key: where is the f**king document that describes these corner cases completely? :-( |
Lets suicide together :) |
Macro expansion is a tricky operation, fraught with nasty corner cases. I've tried some compilers (gcc, clang, lcc, tcc, 9cc, wgtcc, 8cc) for below's code snippet. Unfortunately, only gcc, clang and lcc got right.
The right output is
not
The text was updated successfully, but these errors were encountered: