Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 880247

Summary: sys-devel/gcc-config c99 wrapper should add -P flag
Product: Gentoo Linux Reporter: Hadrien Lacour <hadrien.lacour>
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: UNCONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Hadrien Lacour 2022-11-07 18:23:56 UTC
Otherwise, we get those pesky warnings when doing so:

$ cat hello.c
#include <stdio.h>

int main(void)
{
    puts("Hello world");
}
$ c99 -E hello.c >hello_.c
$ c99 hello_.c
hello_.c:1:3: warning: style of line directive is a GCC extension
    1 | # 0 "hello.c"
      |   ^
hello.c: warning: style of line directive is a GCC extension
<built-in>: warning: style of line directive is a GCC extension
<command-line>: warning: style of line directive is a GCC extension
<command-line>: warning: style of line directive is a GCC extension
hello.c:1:3: warning: style of line directive is a GCC extension
    1 | #include <stdio.h>
      |   ^
hello.c:4:3: warning: style of line directive is a GCC extension
    4 | {
      |   ^
Comment 1 Mike Gilbert gentoo-dev 2022-11-09 16:31:26 UTC
(In reply to Hadrien Lacour from comment #0)
> $ c99 -E hello.c >hello_.c
> $ c99 hello_.c

Why would you do that? This seems like a contrived example.

Do you have a real example of a build system that pre-processes its source files explicitly before compiling them?
Comment 2 Hadrien Lacour 2022-11-10 17:41:56 UTC
My own build system, where in at least one case, I add my own preprocessing that I still want to interact "as expected" with #if and friends (https://git.sr.ht/~q3cpma/posix-build/tree/master/item/build_util.sh#L1345 for reference).

What's the argument against, anyway? -E is specified by POSIX, and without -P, gcc produces non standard C (unless unknown directives are specified as ignored, I don't know).
Comment 3 Mike Gilbert gentoo-dev 2022-11-10 19:03:45 UTC
I suspect losing the line markers would make for less results when debugging. I'm not sure what else (if anything) it would break.
Comment 4 Mike Gilbert gentoo-dev 2022-11-10 19:04:09 UTC
s/less/less useful/
Comment 5 Mike Gilbert gentoo-dev 2022-11-10 19:12:45 UTC
That said, I would guess that very few people actually use the "c99" command, so changing its behavior will have limited impact.
Comment 6 Hadrien Lacour 2022-11-10 19:56:46 UTC
Personally, I think that since the wrapper is just here to satisfy POSIX, conformance should be the first goal.