c to d: types + struct/union alignment

BCS none at anon.com
Wed Dec 30 15:27:44 PST 2009

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;
> }


> 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.

More information about the Digitalmars-d-learn mailing list