This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
pre-processor strips out __attribute__((__packed_)_), is this expected?
- From: Daniel Dickman <didickman at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 27 Mar 2015 20:30:43 -0400
- Subject: pre-processor strips out __attribute__((__packed_)_), is this expected?
- Authentication-results: sourceware.org; auth=none
Hello,
Is there a reason why the pre-processor strips out attributes when
-U__GNUC__ is specified and there is at least 1 #include directive?
This seems like surprising behaviour to me. Here's an example:
$ cat foo.c
#include <limits.h>
struct S {
int a;
} __attribute__((__packed__));
$ egcc -E -U__GNUC__ foo.c | tail -3
struct S {
int a;
} ;
But if I remove the #include directive (or if I drop -U__GNUC__) then
attributes don't get stripped by the pre-processor which is what I
expect to happen.
$ cat foo2.c
struct S {
int a;
} __attribute__((__packed__));
$ egcc -U__GNUC__ -E foo2.c
# 1 "foo2.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "foo2.c"
struct S {
int a;
} __attribute__((__packed__));
I tested gcc 4.2.1 and 4.9.2 on OpenBSD/i386 as well as gcc 4.6.3 on
Linux/x86_64 and they all show the same thing. Any clues would be
appreciated.
gcc (GCC) 4.2.1 20070719
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
egcc (GCC) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.