attribute decl in version decl

Timon Gehr timon.gehr at gmx.ch
Mon Sep 19 06:59:29 PDT 2011


On 09/19/2011 03:37 PM, Trass3r wrote:
>> Change it to the following, and you're golden.
>>
>> extern(System):
>>
>> <Hundreds of OpenGL decls>
>
> That only fixes this particular issue.
>
> I once had the following case that can't be done:
>
> version(V1)
> {
> extern(System):
> }
> else
> {
> extern(C):
> }

You could use the C preprocessor ;). Or this, that does the same thing:

version(V1) private enum _v1=true;
else private enum _v1=false;
mixin((_v1?"extern(System):":"extern(C):")~q{
     // all declarations that should be affected.
});


More information about the Digitalmars-d-learn mailing list