arocc icon indicating copy to clipboard operation
arocc copied to clipboard

CLI: `-D` flag handled differently than gcc/clang

Open ehaas opened this issue 3 years ago • 2 comments

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 avatar May 09 '22 15:05 ehaas

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

ehaas avatar May 09 '22 15:05 ehaas

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 avatar May 09 '22 15:05 Vexu