On Sunday, 26 March 2017 at 07:18:14 UTC, ketmar wrote:
i.e. what compiler does (roughly) is inserting anonymous fields
of the appropriate size *into* the container. for "inner"
aligning compiler inserts anonymous fields *between* other
fields. for "outer" aligning compiler just appends anonymo
zabruk70 wrote:
On Sunday, 26 March 2017 at 06:45:13 UTC, ketmar wrote:
yes. you have a typo in second `writefln`: S1 instead of S2. ;-)
thank you.
another question, related to my first post:
why size of S2.b1 and S2.b2 still 3, not 4?
am i right: then align applied to members, compiler not
On Sunday, 26 March 2017 at 06:45:13 UTC, ketmar wrote:
yes. you have a typo in second `writefln`: S1 instead of S2. ;-)
thank you.
another question, related to my first post:
why size of S2.b1 and S2.b2 still 3, not 4?
am i right: then align applied to members, compiler not change
size of m
On Sunday, 26 March 2017 at 06:38:59 UTC, zabruk70 wrote:
oh sorry sorry - mistyping
ok. DMD use padding, so for real container.sizeof
i should use lastMemeber.offsetof+lastMemeber.sizeof
zabruk70 wrote:
On Sunday, 26 March 2017 at 05:09:15 UTC, ketmar wrote:
most of the time either location or padding will work the same.
hmm.. you ruined my expirence..
i made another experiment.
whould you please explain me S2 size 6?
thank you for you time.
yes. you have a typo in second
On Sunday, 26 March 2017 at 05:09:15 UTC, ketmar wrote:
most of the time either location or padding will work the same.
hmm.. you ruined my expirence..
i made another experiment.
whould you please explain me S2 size 6?
thank you for you time.
https://dpaste.dzfl.pl/9a31b6e370a0
struct S1 //s
zabruk70 wrote:
Thank you ag0aep6g and ketmar!!
I will use additional outside align.
I want packing inside, you are right.
But i check result size with assert() and failed.
But for clearness...
I was thinked, that align not changes SIZE, but changes LOCATION.
I was thinked, that "align(X) unio
On Saturday, 25 March 2017 at 23:36:07 UTC, kinke wrote:
On Saturday, 25 March 2017 at 22:45:22 UTC, ketmar wrote:
zabruk70 wrote:
[...]
`align(1) union Union1` will do the trick.
what you did is members packing. but the union itself is
padded to integer size too. i.e. internal `align` wil
On Saturday, 25 March 2017 at 22:45:22 UTC, ketmar wrote:
zabruk70 wrote:
//DMD 2.073.1 and latest 2.075.0-master-972eaed
//Windows 7 32-bit
union Union1
{
align(1):
byte[5] bytes5;
struct
{
align(1):
char char1;
uint int1;
}
}
void main ()
{
import std.stdio:
On Saturday, 25 March 2017 at 22:54:30 UTC, zabruk70 wrote:
But for clearness...
I was thinked, that align not changes SIZE, but changes
LOCATION.
I was thinked, that "align(X) union Union1"
just force compiler to place Union1 on boundaries of X bytes...
In order for all Union1 instances in a
Thank you ag0aep6g and ketmar!!
I will use additional outside align.
I want packing inside, you are right.
But i check result size with assert() and failed.
But for clearness...
I was thinked, that align not changes SIZE, but changes LOCATION.
I was thinked, that "align(X) union Union1"
just for
zabruk70 wrote:
//DMD 2.073.1 and latest 2.075.0-master-972eaed
//Windows 7 32-bit
union Union1
{
align(1):
byte[5] bytes5;
struct
{
align(1):
char char1;
uint int1;
}
}
void main ()
{
import std.stdio: writefln;
writefln("Union1.sizeof=%d", Union1.sizeof);
On 03/25/2017 11:37 PM, zabruk70 wrote:
union Union1
{
align(1):
byte[5] bytes5;
struct
{
align(1):
char char1;
uint int1;
}
}
void main ()
{
import std.stdio: writefln;
writefln("Union1.sizeof=%d", Union1.sizeof); //prints 8, not 5
}
I'm not sure how the align stuff
//DMD 2.073.1 and latest 2.075.0-master-972eaed
//Windows 7 32-bit
union Union1
{
align(1):
byte[5] bytes5;
struct
{
align(1):
char char1;
uint int1;
}
}
void main ()
{
import std.stdio: writefln;
writefln("Union1.sizeof=%d", Union1.sizeof); //prints 8, not 5
}
I expe
14 matches
Mail list logo