extern(C) enum
bitwise
bitwise.pvt at gmail.com
Mon Sep 18 02:04:49 UTC 2017
On Monday, 18 September 2017 at 00:12:49 UTC, Mike Parker wrote:
> On Sunday, 17 September 2017 at 19:16:06 UTC, bitwise wrote:
>> [...]
>
> I've been maintaining bindings to multiple C libraries
> (including Freetype 2 bindings) for 13 years now. I have never
> encountered an issue with an enum size mismatch. That's not to
> say I never will.
For which platforms?
I would have to actually go through the specs for each compiler
of each platform to make sure before I felt comfortable accepting
that int-sized enums were defacto standard.
I would be worried about iOS, for example.
The following code will run fine on Windows, but crash on iOS due
to the misaligned access:
char data[8];
int i = 0xFFFFFFFF;
int* p = (int*)&data[1];
*p++ = i;
*p++ = i;
*p++ = i;
I remember this issue presenting due to a poorly written
serializer I used once (no idea who wrote it ;) and it makes me
wonder what kind of other subtle differences there may be.
I think there may be a few (clang and gcc?) different choices of
compiler for Android NDK as well.
More information about the Digitalmars-d-learn
mailing list