Different struct sizeof between linux and windows

Andre Pany via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 16 23:54:36 PDT 2016


Hi,

I try to write a wrapper for a library. I translated the C++ 
header coding.
While the wrapper is working fine in linux, on windows the 
library complains
the struct size is too small while calling it.
This is the reduced example:

import core.stdc.time: time_t;
import std.stdio;
	
enum Bar
{
	UNDEFINED = 0,
}
	
struct Foo1
{
    Bar bar;
}
	
struct Foo2
{
    time_t issuedAt;
    Bar bar;
}
	
struct Foo3
{
    time_t issuedAt;
}

void main()	
{
	writeln(Foo1.sizeof);
	writeln(Foo2.sizeof);
	writeln(Foo3.sizeof);
}


I compile the application using dub --arch=x86_64 on windows and
just dub on linux.

Results on linux:
4
16
8

Results on windows:
4
8
4

Is this behavior correct?

Kind regards
André



More information about the Digitalmars-d-learn mailing list