Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 11, 2008 Struct with no alignment ? | ||||
---|---|---|---|---|
| ||||
Hello, Is there a way to use a sort of struct which is not submit to alignment ? For example : struct MyStruct { long a; int b; } have a size of 16 bytes. But I only need 12. Is there a way to have a sort of struct without alignment's system ? Thanks in advance, TSalm. |
October 11, 2008 Re: Struct with no alignment ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to tsalm | align(1) struct{ ... } |
October 11, 2008 Re: Struct with no alignment ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to tsalm | tsalm wrote: > Hello, > > Is there a way to use a sort of struct which is not submit to alignment ? > > For example : > > struct MyStruct { long a; int b; } > > have a size of 16 bytes. > But I only need 12. > > Is there a way to have a sort of struct without alignment's system ? > > > Thanks in advance, > TSalm. align(1) struct MyStruct { long a; int b; } http://www.digitalmars.com/d/1.0/attribute.html#align |
October 11, 2008 Re: Struct with no alignment ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to torhu |
>> Hello,
>> Is there a way to use a sort of struct which is not submit to alignment ?
>> For example :
>> struct MyStruct { long a; int b; }
>> have a size of 16 bytes.
>> But I only need 12.
>> Is there a way to have a sort of struct without alignment's system ?
>> Thanks in advance,
>> TSalm.
>
> align(1) struct MyStruct { long a; int b; }
>
> http://www.digitalmars.com/d/1.0/attribute.html#align
Awesome! D is really an excellent language
Thanks you Torhu and Frank Benoit.
|
Copyright © 1999-2021 by the D Language Foundation