Structs can't be zero bytes in size?

Vladimir Panteleev vladimir at thecybershadow.net
Mon Sep 2 20:08:25 PDT 2013


On Tuesday, 3 September 2013 at 02:31:44 UTC, Lionello Lunesu 
wrote:
> On 9/3/13 8:34, Vladimir Panteleev wrote:
>> On Tuesday, 3 September 2013 at 00:05:04 UTC, Walter Bright 
>> wrote:
>>> On 9/2/2013 4:57 PM, Dylan Knutson wrote:
>>>> Can someone shed some light on this?
>>>
>>> It comes from C. This was done in C so that addresses of 
>>> struct
>>> instances will always be unique.
>>
>> Why is that important, and why does D need it?
>>
>> In C, this might make some sense, however empty structs are 
>> much more
>> useful in D, e.g. for metaprogramming.
>
> struct Z {};
> Z a, b;
> assert(&a != &b);

Yes, but why is this important? If you declare Z as "alias int[0] 
Z", the assert passes, so why is this property needed for structs 
but not static arrays?


More information about the Digitalmars-d mailing list