attribute decl in version decl

Ellery Newcomer ellery-newcomer at utulsa.edu
Mon Sep 19 13:08:07 PDT 2011


On 09/19/2011 08:59 AM, Timon Gehr wrote:
> 
> 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.
> });

<code golf>

or this:

version(linux){
 extern(C):
  mixin(s);
}
version(Win32){
 extern(Windows):
 mixin(s);
}

enum s = q{
 <hundreds of opengl decls>
};

</code golf>


More information about the Digitalmars-d-learn mailing list