| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
January 01, 2011 sizeof | ||||
|---|---|---|---|---|
| ||||
Hello. Been trying to link to some C code with gdc on 64 bit, and I've been racking my brain over the following:
//tok.d
import std.stdio;
struct x {
union _u_{
ulong uq;
struct _s_ {
ushort dw;
uint dd;
};
_s_ s;
};
_u_ u;
ushort zz;
}
void main(){
writeln(x.sizeof);
}
//tok.c
#include <stdint.h>
#include <stdio.h>
struct x {
union {
uint64_t uq;
struct {
uint16_t dw;
uint32_t dd;
} s;
} u;
uint16_t zz;
};
void main(){
printf("%d\n", sizeof(struct x));
}
the d code prints 12, and the C code prints 16. Should I be expecting the two to be the same?
| ||||
January 02, 2011 Re: sizeof | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ellery Newcomer | Ellery Newcomer wrote:
> d code prints 12
prints 16 ( DMD 2.051 on win32)
-manfred
| |||
January 02, 2011 Re: sizeof | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Manfred_Nowak | curious. prints 12, DMD 2.051 linux
On 01/01/2011 06:15 PM, Manfred_Nowak wrote:
> Ellery Newcomer wrote:
>
>> d code prints 12
>
> prints 16 ( DMD 2.051 on win32)
> -manfred
| |||
January 02, 2011 Re: sizeof | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ellery Newcomer | Ellery Newcomer wrote:
> prints 12, DMD 2.051 linux
So we have:
( linux32 , dmd 2.051) -> 12
( linux32 , gdc) -> 12
( linux64 , gdc) -> 12
( linux64 , ldc) -> 16
( win32 , dmd 2.051) -> 16
( cygwin32, gdc) -> 16
Congrats Ellery: this looks like a stairway to hell.
-manfred
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply