On Friday, 15 September 2017 at 06:57:31 UTC, rikki cattermole wrote:
On 15/09/2017 5:15 AM, bitwise wrote:
I translated the headers for FreeType2 to D, and in many cases, enums are used as struct members.

If I declare an extern(C) enum in D, is it guaranteed to have the same underlying type and size as it would for a C compiler on the same platform?

No need for extern(C). Be as specific as you need, but most likely you won't need to (e.g. first is automatically 0).

enum Foo : int {
        Start = 0,
        StuffHere
        End
}

This is for D/C interop though.

enum E {
    A, B, C
}

struct S {
   E e;
}

So based on the underlying type chosen by each compiler, the size of struct S could change.

I can't strongly type the D enums to match, because I don't know what size the C compiler will make 'E', unless D somehow gauntness the same enum-sizing as the C compiler would.

Reply via email to