View mode: basic / threaded / horizontal-split · Log in · Help
June 08, 2012
align number
version(Win64) {
const int align_number = 8;
} else {
const int align_number = 4;
}

align(align_number):

...long code...
June 08, 2012
Re: align number
On Friday, 8 June 2012 at 01:46:15 UTC, Katayama Hirofumi MZ 
wrote:
> version(Win64) {
> const int align_number = 8;
> } else {
> const int align_number = 4;
> }
>
> align(align_number):
>
> ...long code...

align(size_t.sizeof); ?
June 08, 2012
Re: align number
On Friday, 8 June 2012 at 02:51:57 UTC, Bernard Helyer wrote:
> On Friday, 8 June 2012 at 01:46:15 UTC, Katayama Hirofumi MZ 
> wrote:
>> version(Win64) {
>> const int align_number = 8;
>> } else {
>> const int align_number = 4;
>> }
>>
>> align(align_number):
>>
>> ...long code...
>
> align(size_t.sizeof); ?

Well that doesn't seem to work.
June 08, 2012
Re: align number
On 6/8/12, Bernard Helyer <b.helyer@gmail.com> wrote:
> Well that doesn't seem to work.

Try this:

version(Win64) {
align(8):
} else {
align(4):
}
June 08, 2012
Re: align number
08.06.2012 7:31, Andrej Mitrovic написал:
> On 6/8/12, Bernard Helyer<b.helyer@gmail.com>  wrote:
>> Well that doesn't seem to work.
>
> Try this:
>
> version(Win64) {
> align(8):
> } else {
> align(4):
> }

This will not work as you expect. Just like
---
version(v1) { class }
else { struct }
S { int i; }
---
will not compile. It's D and there is no C preprocessor:
---
version(Win64) {
  align(8):
  ... aligned 8 ...
} else {
  align(4):
  ... aligned 4 ...
}
... default aligned ...
---

-- 
Денис В. Шеломовский
Denis V. Shelomovskij
June 08, 2012
Re: align number
On Friday, 8 June 2012 at 04:16:18 UTC, Denis Shelomovskij wrote:
> It's D and there is no C preprocessor:
> ---
> version(Win64) {
>   align(8):
>   ... aligned 8 ...
> } else {
>   align(4):
>   ... aligned 4 ...
> }
> ... default aligned ...
> ---

The code overlaps and it is not much smart.
June 08, 2012
Re: align number
template Aligned(alias Content)
{
 static if(size_t.sizeof==4)
  align(4) struct Aligned{ mixin Content; }
 else
  align(8) struct Aligned{ mixin Content; }
}
June 08, 2012
Re: align number
On 08.06.2012 23:16, Kagamin wrote:
> template Aligned(alias Content)
> {
> static if(size_t.sizeof==4)
> align(4) struct Aligned{ mixin Content; }
> else
> align(8) struct Aligned{ mixin Content; }
> }

Ain't structs aligned on word boundary by default?

-- 
Dmitry Olshansky
June 28, 2012
Re: align number
version(Win64) {
    private const const_align = 8;
} else {
    private const const_align = 1;
}
align(const_align):
...long code...

Please support me!!  Please, please!
August 04, 2012
Re: align number
private template Aligned() {
    ...long code...
}

version(Win64) {
    align(8): mixin Aligned!();
} else {
    align(1): mixin Aligned!();
}

---END of THREAD---
Top | Discussion index | About this forum | D home