Re: Re: Etherboot 5.5
Marty Connor <[email protected]>
| Newsgroups | gmane.network.etherboot.devel |
|---|---|
| Message-ID | <[email protected]> |
On May 23, 2005, at 6:08 AM, Georg Baum wrote:
> Marty Connor wrote:
>> For efficiency and aesthetic reasons we use features that seem to
>> change between various releases. I am not certain if these changes
>> are
>> bugs, compatibility with ANSI C, or for other reasons. I would really
>> like to understand what the deal is.
>
> I don't know for sure either (since I am not programming much in C but
> rather in C++ lately), but what I know is that unnamed structs/unions
> neither work with very old nor very new compilers, so we should not use
> them.
For what it's worth, the GCC documentation says:
=============
6.48. Unnamed struct/union fields within structs/unions.
For compatibility with other compilers, GCC allows you to define a
structure or union that contains, as fields, structures and unions
without names. For example:
struct {
int a;
union {
int b;
float c;
};
int d;
} foo;
In this example, the user would be able to access members of the
unnamed union with code like foo.b. Note that only unnamed structs and
unions are allowed, you may not have, for example, an unnamed int.
You must never create such structures that cause ambiguous field
definitions. For example, this structure:
struct {
int a;
struct {
int a;
};
} foo;
It is ambiguous which a is being referred to with foo.a. Such
constructs are not supported and must be avoided. In the future, such
constructs may be detected and treated as compilation errors.
=============
Experience, however, has shown that this causes problems with some
version of GCC, and whether it is a case of "ambiguous field
definitions" as mentioned above, or just flat-out bugs in GCC, I agree
that we should avoid these constructs and name these structs and
unions, for maximum toolset compatibility. If anyone has a good reason
why we need unnamed struct/union fields within structs/unions, please
comment.
Marty
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005