This is the mail archive of the
mailing list for the GCC project.
Re: pre-processor strips out __attribute__((__packed_)_), is this expected?
- From: Mikhail Maltsev <maltsevm at gmail dot com>
- To: Daniel Dickman <didickman at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 28 Mar 2015 05:50:15 +0300
- Subject: Re: pre-processor strips out __attribute__((__packed_)_), is this expected?
- Authentication-results: sourceware.org; auth=none
- References: <CAMhqYKquCGOtAKhDdMz1Pd-nu+i43KqhXmkJrDYEgGAruxqzDw at mail dot gmail dot com>
28.03.2015 3:30, Daniel Dickman wrote:
> 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>
Yes, this is intended behavior. The GNU C Library (glibc) defines
__attribute__ as a macro, which expands to whitespace if __GNUC__ is not
#if !defined __GNUC__ || __GNUC__ < 2
# define __attribute__(xyz) /* Ignore */
It is defined in such way to make the code compatible with other
compilers which do not support __attribute__ syntax.