Skip to content
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

macro expansion is not correct #153

Open
the-die opened this issue Jan 22, 2025 · 1 comment
Open

macro expansion is not correct #153

the-die opened this issue Jan 22, 2025 · 1 comment

Comments

@the-die
Copy link

the-die commented Jan 22, 2025

chibicc -E macro.c

will get

BAR() 1

however

gcc -E macro.c

will get

BAR_I ()() 1 1 1
// macro.c
#define EMPTY()
#define DEFER(id) id EMPTY()
#define EXPAND(...) __VA_ARGS__
#define BAR_I() BAR
#define BAR()  DEFER(BAR_I)()() 1
EXPAND(EXPAND(BAR()))
@fuhsnn
Copy link

fuhsnn commented Jan 23, 2025

This fork has it fixed: https://github.com/n0tknowing/chibicc

Or checkout my fork's alternative algorithm fuhsnn/slimcc@c3a1194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants