Structs can't be zero bytes in size?

Walter Bright newshound2 at digitalmars.com
Tue Sep 3 13:07:54 PDT 2013


On 9/3/2013 1:01 PM, Dylan Knutson wrote:
> Perhaps something like `enum struct Foo;`, to indicate that it's just a
> compile-time used distinct type, and not a value? Just throwing that out there.
> I'm sure there is a better way to indicate that a type is just used as a
> type/namespace, without a value persay.

If you need a zero sized object in D,

alias whatever[0] zeroSizeObject;

> When you say retain C compatibility, do you mean having C code which makes use
> of empty structs still be compile-able with the D compiler? Or D code
> inter-oping with external C libraries?

Yes.


More information about the Digitalmars-d mailing list