From: Christophe A. <chr...@la...> - 2004-07-21 22:11:17
|
Well, more precisely : in C you always need the prefix "struct" for a struct name. for example : struct object { ... }; struct object *new_object(); void init_object(struct object *object); if you want to avoit to prefix "struct" you must use a typedef declaration : typedef struct object { ... } object; Now, in C++, you are not forced to prefix "struct", just give the name and it knows whether it is a struct name, but indeed I noticed that g++ is okay when using the prefix "struct" explicitly (prefix "class" also works most time). My opinion is that it should be standard. Anyway if you want OpenC++ to be able to parse C source, you absolutely need to have this prefix, because using "object" without its typedef declaration would lead a normal C compiler to think it is an unknown type, whereas a C++ compiler would recognize as a "struct object". Regards ----- Original Message ----- From: "Stefan Seefeld" <se...@sy...> To: <ope...@li...> Sent: Wednesday, July 21, 2004 1:17 PM Subject: Re: [Opencxx-users] parse error on valid code > Christophe Avoinne wrote: > > Forward declaration is not necessary with pointer (always a 4-byte unsigned > > integer for ia32), but you must use a tag name for the structure to resolve > > this lack of information : > > > > typedef struct Link_s { > > struct Link_s *next; > > int value; > > } Link; > > interesting. I wasn't sure how standard compliant such a construct is > (knowing that it comes from C...). > Anyways, the important point here seems to be that the 'struct' tag > serves the same purpose as the 'typename' keyword, i.e. it provides > a hint to the parser to disambiguate the expression. > > Regards, > Stefan > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click > _______________________________________________ > Opencxx-users mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/opencxx-users |