Question about GNU cpp -P

Martin Sebor msebor@gmail.com
Tue Aug 18 18:18:00 GMT 2015


On 08/15/2015 02:42 PM, W. Michael Petullo wrote:
> I am using:
>
> 	cpp -C -P -nostdinc -std=c99 -Werror
>
> to process something that is not C. Everything works, except that one
> side effect of "-P" is that consecutive newlines are compressed into one.
>
> Is this intentional? Why? Is there a way to avoid collapsing consecutive
> newlines when using "cpp -P"?

My guess based on stepping through the code and the absence of tests
for this behavior is that it's not intentional, and possibly a bug.

A quick hack to the print_line_1 function in gcc/c-family/c-ppoutput.c
makes it (almost) work and  doesn't cause any of the cmdlne-dU-* tests
to fail, so a fix shouldn't be too onerous.

With -P, when line directives aren't emitted, it seems reasonable to
expect the preprocessor to preserve the newlines. I suggest to open
a bug in Bugzilla for this.

Martin



More information about the Gcc-help mailing list