dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]another bug in pnet


From: Fergus Henderson
Subject: Re: [DotGNU]another bug in pnet
Date: Tue, 14 Jan 2003 04:18:23 +1100
User-agent: Mutt/1.3.28i

On 12-Jan-2003, Gopal V <address@hidden> wrote:
> 
> > Frankly, I don't know why the spec has a problem with zero-sized structs.  

Indeed.

> #include <stdio.h>
> struct Foo
> {
> };
> int main()
> {
>       printf("%d\n",sizeof(struct Foo));
>       return 0;
> }
> 
> How would this work in our compiler .... (people might argue that 
> having an empty struct is stupid .. but some programs #ifdef out
> stuff and empty structs are not impossible in useful code).
> 
> Gcc gives the nice answer '0' , what would VC.Net give ?...

The C++ standard requires that the answer for that program be > 0.
Most (all?) C++ implementations therefore give the answer '1'.

GNU C currently gives '0', but this is going to change in a future
version, for compatibility with C++.  The old behaviour of size zero
will be obtainable, but to get it, you'll have to use an attribute
(`__attribute__((allow_zero_size))', or something like that).

-- 
Fergus Henderson <address@hidden>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]