c to d: types + struct/union alignment
Michael P.
baseball.mjp at gmail.com
Wed Dec 30 15:50:32 PST 2009
BCS Wrote:
> Hello Michael P.,
>
> > I'm converting some C headers into D, and had some questions.
> > 1. What is the equivalent of a 'short int' in D?
> > e.g:
> > struct ScePspSRect {
> > short int x;
> > short int y;
> > short int w;
> > short int h;
> > }
>
> short
>
> > 3.
> > typedef uint8_t u8;
> > typedef uint16_t u16;
> > typedef uint32_t u32;
> > typedef uint64_t u64;
> > typedef int8_t s8;
> > typedef int16_t s16;
> > typedef int32_t s32;
> > typedef int64_t s64;
> > Would it be okay to be make/alias all of the uintxx_t to 'uint' and
> > all of the intxx_t to 'int'?
>
> no, uint16_t is (I assume) 16 bits long and uint32_t is 32 bits long. if
> you get them mixed up (as the aliasing you proposed would do) you will get
> problems passing struct to non-D code.
>
>
Okay. I'll look at where they came from and see what they are defined as. They come from a file called stdint.h.
Also, would short unsigned int be a 'ushort' then?
More information about the Digitalmars-d-learn
mailing list