Thread overview
custom alignment (__declspec(align))
Jan 24, 2009
Alexander
Jan 24, 2009
Walter Bright
Jan 26, 2009
Sergey
Jan 27, 2009
Walter Bright
Jan 27, 2009
Sergey
Jan 27, 2009
Cesar Rabak
Jan 28, 2009
Sergey
Mar 05, 2009
Walter Bright
January 24, 2009
Hello,

Is there a way to specify custom alignment for structures and variables, something like __declspec(align(<alignment>)) ?

Thanks.
January 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
January 26, 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
January 27, 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.
January 27, 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.
January 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.
Just for a better grasp on the issue: why is there any need to "fix" such a thing?

IMNHO this is not a fault or defect of the compiler, or is it?
January 28, 2009
> IMNHO this is not a fault or defect of the compiler, or is it?
Well, yes, sorry for putting it wrong,

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.
> Just for a better grasp on the issue: why is there any need to "fix" such a thing?
> 
> IMNHO this is not a fault or defect of the compiler, or is it?
March 05, 2009
Sergey wrote:
> Is this feature going to be implemented any time soon ?

Not in the near future.