This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pre-processor strips out __attribute__((__packed_)_), is this expected?


28.03.2015 3:30, Daniel Dickman wrote:
> 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>

Yes, this is intended behavior. The GNU C Library (glibc) defines
__attribute__ as a macro, which expands to whitespace if __GNUC__ is not
defined:

#if !defined __GNUC__ || __GNUC__ < 2
# define __attribute__(xyz) /* Ignore */
#endif

It is defined in such way to make the code compatible with other
compilers which do not support __attribute__ syntax.

-- 
Regards,
    Mikhail Maltsev


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]