* Difference in -E output
@ 2022-10-27 20:22 Tom Kacvinsky
2022-10-27 22:28 ` Segher Boessenkool
0 siblings, 1 reply; 3+ messages in thread
From: Tom Kacvinsky @ 2022-10-27 20:22 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1: Type: text/plain, Size: 1206 bytes --]
I am working on an issue that involves our tool depending on the
preprocessed output from gcc -E.
This simple test program exhibits the problem
#include <stdlib.h>
int main() {
return EXIT_SUCCESS;
}
With some elision, this preprocesses to:
# 3 "test.c"
int main() {
return
# 4 "test.c" 3 4
0
# 4 "test.c"
;
}
Notice how when the macro EXIT_SUCCESS is expanded, we get several lines
around the 0?
This is happening for us with GCC 8.3. But using something as early as
4.8.5 (yeah, I know,
bad idea), we get this:
int main() {
return 0;
}
I am pretty sure this is an intentional change. What I'd like to know is
if there is a way of
reverting back to the former behavior? I looked at
https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options
But didn't see anything that jumped out at me and said "this is how you can
work around it"
I did a modicum of bi-secting to see that this change was introduced
somewhere between gcc
4.9.3 and 5.4.0. I can go deeper to figure out which version actually
broke it if you would find
it helpful.
If anyone has some ideas on this, I'd appreciate hearing them.
Thanks,
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Difference in -E output
2022-10-27 20:22 Difference in -E output Tom Kacvinsky
@ 2022-10-27 22:28 ` Segher Boessenkool
2022-10-27 22:33 ` Tom Kacvinsky
0 siblings, 1 reply; 3+ messages in thread
From: Segher Boessenkool @ 2022-10-27 22:28 UTC (permalink / raw)
To: Tom Kacvinsky; +Cc: gcc-help
On Thu, Oct 27, 2022 at 04:22:11PM -0400, Tom Kacvinsky via Gcc-help wrote:
> I am working on an issue that involves our tool depending on the
> preprocessed output from gcc -E.
> # 4 "test.c" 3 4
>
> 0
>
> # 4 "test.c"
>
> ;
>
> }
>
>
> Notice how when the macro EXIT_SUCCESS is expanded, we get several lines
> around the 0?
I don't get any of the blank lines you have though?
> This is happening for us with GCC 8.3. But using something as early as
> 4.8.5 (yeah, I know,
>
> bad idea), we get this:
>
>
> int main() {
>
> return 0;
>
> }
>
>
> I am pretty sure this is an intentional change. What I'd like to know is
> if there is a way of
>
> reverting back to the former behavior? I looked at
-P will do what you want (as a side effect though). -traditional also
works (and that one is more intentional). Neither of those does *only*
this, but either may be usable for your purposes.
Have fun,
Segher
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Difference in -E output
2022-10-27 22:28 ` Segher Boessenkool
@ 2022-10-27 22:33 ` Tom Kacvinsky
0 siblings, 0 replies; 3+ messages in thread
From: Tom Kacvinsky @ 2022-10-27 22:33 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]
On Thu, Oct 27, 2022 at 6:30 PM Segher Boessenkool <
segher@kernel.crashing.org> wrote:
> On Thu, Oct 27, 2022 at 04:22:11PM -0400, Tom Kacvinsky via Gcc-help wrote:
> > I am working on an issue that involves our tool depending on the
> > preprocessed output from gcc -E.
>
> > # 4 "test.c" 3 4
> >
> > 0
> >
> > # 4 "test.c"
> >
> > ;
> >
> > }
> >
> >
> > Notice how when the macro EXIT_SUCCESS is expanded, we get several lines
> > around the 0?
>
> I don't get any of the blank lines you have though?
>
> > This is happening for us with GCC 8.3. But using something as early as
> > 4.8.5 (yeah, I know,
> >
> > bad idea), we get this:
> >
> >
> > int main() {
> >
> > return 0;
> >
> > }
> >
> >
> > I am pretty sure this is an intentional change. What I'd like to know is
> > if there is a way of
> >
> > reverting back to the former behavior? I looked at
>
> -P will do what you want (as a side effect though). -traditional also
> works (and that one is more intentional). Neither of those does *only*
> this, but either may be usable for your purposes.
>
A colleague informed me that -ftrack-macro-expansion=0 does exactly what I
want.
Said colleague also told me to call them the next time a question like this
came up. Haha
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-27 22:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 20:22 Difference in -E output Tom Kacvinsky
2022-10-27 22:28 ` Segher Boessenkool
2022-10-27 22:33 ` Tom Kacvinsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).