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

CLI: -D flag handled differently than gcc/clang #281

Open
ehaas opened this issue May 9, 2022 · 2 comments
Open

CLI: -D flag handled differently than gcc/clang #281

ehaas opened this issue May 9, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@ehaas
Copy link
Collaborator

ehaas commented May 9, 2022

From the GCC docs for -D name=definition:

The contents of definition are tokenized and processed as if they appeared during translation phase three in a ‘#define’ directive. In particular, the definition is truncated by embedded newline characters.`

So newline splicing should not happen for -D definitions.

For a program that contains the single token FOO, clang produces the following output (gcc is the same but does not issue a warning):

➜  ~ clang -E -DFOO="F\\
OO" test.c
warning: macro 'FOO' contains embedded newline; text after the newline is ignored
F\
1 warning generated.
@ehaas
Copy link
Collaborator Author

ehaas commented May 9, 2022

I think we could implement this by just truncating the argument at the first newline before writing it to macro_buf in main.zig:parseArgs

@Vexu
Copy link
Owner

Vexu commented May 9, 2022

I think we could implement this by just truncating the argument at the first newline before writing it to macro_buf in main.zig:parseArgs

Sounds good to me.

@Vexu Vexu added the enhancement New feature or request label May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants