Is this a bug or illegal code?

safety0ff via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 29 08:06:26 PDT 2014


On Thursday, 29 May 2014 at 15:02:48 UTC, Steven Schveighoffer 
wrote:
> Even if that is valid code, you are much better off using enums 
> and static if.
>
> enum includeSomeFeature = ...
>
> static if(includeSomeFeature)
> {
>  ...
> }
>
> These work much more like #defines, and can be seen outside the 
> module.
>
> -Steve

Thanks, the following works:
mixin("enum hasFoo = true;");
static if(hasFoo)
{
void main(){}	
}


More information about the Digitalmars-d-learn mailing list