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