c - gcc: fixing -pedantic "unnamed structure" warning -



c - gcc: fixing -pedantic "unnamed structure" warning -

i'm trying code elsewhere (specifically, here), compile without warnings when gcc given -pedantic flag. problem bit of code:

struct __attribute__ ((aligned(nlmsg_alignto))) { struct nlmsghdr nl_hdr; /* unnamed struct start. */ struct __attribute__ ((__packed__)) { struct cn_msg cn_msg; struct proc_event proc_ev; }; /* unnamed struct end. */ } nlcn_msg;

no matter seek set in name structure, results in compilation error. there way modify given code satisfy -pedantic? or there way tell gcc not issues warning piece of code?

which standard compiling to?

given code:

#define nlmsg_alignto 4 struct nlmsghdr { int x; }; struct cn_msg { int x; }; struct proc_event { int x; }; struct __attribute__ ((aligned(nlmsg_alignto))) { struct nlmsghdr nl_hdr; /* unnamed struct start. */ struct __attribute__ ((__packed__)) { struct cn_msg cn_msg; struct proc_event proc_ev; }; /* unnamed struct end. */ } nlcn_msg;

compiling c99 mode, errors:

$ gcc -o3 -g -std=c99 -wall -wextra -wmissing-prototypes -wstrict-prototypes \ -wold-style-definition -werror -pedantic -c x2.c x2.c:13:6: error: iso c99 doesn’t back upwards unnamed structs/unions [-werror=pedantic] }; ^ cc1: warnings beingness treated errors $

compiling c11 mode, no errors:

$ gcc -o3 -g -std=c11 -wall -wextra -wmissing-prototypes -wstrict-prototypes \ -wold-style-definition -werror -pedantic -c x2.c $

c gcc struct compiler-warnings gcc-pedantic

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -