简体   繁体   中英

gcc struggling with struct foo_v1 : foo_v2 { a; };

my gcc (9.1.0) struggle with following structure definition

struct foo_v1 : foo_v2 { a; };

i guess it could be a matter of coding version such as ansi or c99.

reading 9.4.0 i could not find <struct a: b { c; };> notation.

please could anyone give me a hint where to find standard defining such a notation or how to compile with gcc.

have a great day

how to compile with gcc.

It is not valid C syntax. It is not possible to compile it with gcc as a C source code. It is also not a common extension in common C compilers.


It may be possible to compile the following with a C++ compiler (which makes the line compile-able after adding two lines and adding -xc++ to gcc ):

struct foo_v2 { int stuff; };
#define a  int variable
struct foo_v1 : foo_v2 { a; };

The presented line in the question, on its own, is not valid C++ code anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM