Compiling glibc-2.3.2 with gcc-3.4 yields "string2.h:80: warning: `packed' attribute ignored"
Jim Wilson
wilson@tuliptree.org
Wed Aug 20 01:41:00 GMT 2003
Dan Kegel wrote:
> # define __STRING2_COPY_TYPE(N) \
> typedef struct { unsigned char __arr[N];
> } \
> __STRING2_COPY_ARR##N __attribute__ ((packed))
This looks like a glibc problem. The syntax for typedef is roughly
typedef <type> <name>;
glibc put the attribute at the end, which means it is after <name>, but
attaching a packed attribute to a name is useless, and hence it is being
ignored. If you want the packed attribute to do something, it needs to
be attached to <type> intead of <name>.
It looks like the only change here is that gcc used to silently ignore
the misplaced attribute, and is now warning about it which is an
improvement. Trying gcc-3.2, I get no warning, and the struct is not
packed either.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
More information about the Gcc
mailing list