Re: union alignment

2016-05-21 Thread tsbockman via Digitalmars-d-learn
On Wednesday, 18 May 2016 at 01:46:37 UTC, tsbockman wrote: Shouldn't a union type always have an `alignof` at least as great as the `alignof` for its largest member? Apparently not; it's actually DMD and LDC that are wrong here: http://bugzilla.gdcproject.org/show_bug.cgi?id=226

Re: union alignment

2016-05-21 Thread Iain Buclaw via Digitalmars-d-learn
On Wednesday, 18 May 2016 at 01:46:37 UTC, tsbockman wrote: Shouldn't a union type always have an `alignof` at least as great as the `alignof` for its largest member? On x86, there's a difference between the type alignment and the field alignment. The type align of ulong and double are 8 b

union alignment

2016-05-17 Thread tsbockman via Digitalmars-d-learn
Is this a bug? --- module app; union Foo(A, B) { A a; B b; } void main() { alias F = Foo!(double, ulong); import std.stdio, std.algorithm; writefln("sizeof: (%s >= %s) == %s", F.sizeof, max(double.sizeof, ulong.sizeof), F.sizeof >= max(double.sizeof, ulong.s

Re: c to d: types + struct/union alignment

2009-12-30 Thread bearophile
Michael P.: >Also, would short unsigned int be a 'ushort' then?< In D ushort is an unsigned integer 16 bits long. While I think in C short unsigned int is not guaranteed to be 16 bit wide. The same is true for unsigned short / uint. Bye, bearophile

Re: c to d: types + struct/union alignment

2009-12-30 Thread Michael P.
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. > > type

Re: c to d: types + struct/union alignment

2009-12-30 Thread BCS
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; typede

c to d: types + struct/union alignment

2009-12-30 Thread 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; } 2. If I have this union in C: typedef union ScePsp