c++ - custom alignment (__declspec(align))
- Alexander <sergeyn funcom.com> Jan 24 2009
- Walter Bright <newshound1 digitalmars.com> Jan 24 2009
- Sergey <sergeyn funcom.com> Jan 26 2009
- Walter Bright <newshound1 digitalmars.com> Jan 26 2009
- Sergey <sergeyn funcom.com> Jan 27 2009
- Cesar Rabak <crabak acm.org> Jan 27 2009
- Sergey <sergeyn funcom.com> Jan 28 2009
- Walter Bright <newshound1 digitalmars.com> Mar 05 2009
Hello, Is there a way to specify custom alignment for structures and variables, something like __declspec(align(<alignment>)) ? Thanks.
Jan 24 2009
Alexander wrote:Is there a way to specify custom alignment for structures and variables, something like __declspec(align(<alignment>)) ?
http://www.digitalmars.com/ctg/pragmas.html#pack
Jan 24 2009
As far as I understood the documentation this pragma sets alignment for members only, but not instances of that struct or class. For example, how would I declare an int variable, which would appear at 128 byte aligned address ? Thanks. Walter Bright wrote:Alexander wrote:Is there a way to specify custom alignment for structures and variables, something like __declspec(align(<alignment>)) ?
http://www.digitalmars.com/ctg/pragmas.html#pack
Jan 26 2009
Sergey wrote:As far as I understood the documentation this pragma sets alignment for members only, but not instances of that struct or class. For example, how would I declare an int variable, which would appear at 128 byte aligned address ?
There's currently no way to do it statically, as segments themselves are aligned on 16 byte boundaries. You could do it dynamically by allocating a chunk of memory and picking a 128 byte aligned piece of it.
Jan 26 2009
Walter Bright wrote:Sergey wrote:As far as I understood the documentation this pragma sets alignment for members only, but not instances of that struct or class. For example, how would I declare an int variable, which would appear at 128 byte aligned address ?
There's currently no way to do it statically, as segments themselves are aligned on 16 byte boundaries. You could do it dynamically by allocating a chunk of memory and picking a 128 byte aligned piece of it.
Is it in the plans to get that fixed ? Thanks, Sergey.
Jan 27 2009
Sergey escreveu:Walter Bright wrote:Sergey wrote:As far as I understood the documentation this pragma sets alignment for members only, but not instances of that struct or class. For example, how would I declare an int variable, which would appear at 128 byte aligned address ?
There's currently no way to do it statically, as segments themselves are aligned on 16 byte boundaries. You could do it dynamically by allocating a chunk of memory and picking a 128 byte aligned piece of it.
Is it in the plans to get that fixed ? Thanks, Sergey.
such a thing? IMNHO this is not a fault or defect of the compiler, or is it?
Jan 27 2009
IMNHO this is not a fault or defect of the compiler, or is it?
Anyway, Is this feature going to be implemented any time soon ? Thanks. Cesar Rabak wrote:Sergey escreveu:Walter Bright wrote:Sergey wrote:As far as I understood the documentation this pragma sets alignment for members only, but not instances of that struct or class. For example, how would I declare an int variable, which would appear at 128 byte aligned address ?
There's currently no way to do it statically, as segments themselves are aligned on 16 byte boundaries. You could do it dynamically by allocating a chunk of memory and picking a 128 byte aligned piece of it.
Is it in the plans to get that fixed ? Thanks, Sergey.
such a thing? IMNHO this is not a fault or defect of the compiler, or is it?
Jan 28 2009
Sergey wrote:Is this feature going to be implemented any time soon ?
Not in the near future.
Mar 05 2009








Walter Bright <newshound1 digitalmars.com>