Conditional compilation inside asm and enum declarations

Don nospam at nospam.com
Wed Jul 15 00:11:12 PDT 2009


Walter Bright wrote:
> Don wrote:
>> In this case you may have a long function, with only a single 
>> instruction right in the middle which needs to be changed.
> 
> void foo()
> {
>     asm
>     {
>         mov EAX,EAX;
>     ... lots more instructions ...
>     }
>     version (bar) asm
>     {
>         mov EAX,EAX;
>     }
>     asm
>     {
>     ... even more instructions ...
>         mov EAX,EAX;
>     }
> }
Yes, of course, that is what I do. It's ugly, though, especially since 
you want to _remove_ code for version(bar).
asm {
...
}
version(D_PIC) {} else asm {
...
}
asm {
...
}



More information about the Digitalmars-d mailing list