Version very simple?

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Sun Feb 27 08:27:11 PST 2011


On Sun, 27 Feb 2011 15:52:01 +0100, simendsjo wrote:

> I'm having some problems grokking version.
> 
> How would I translate this simple C macro? #if !defined(IDENT) ||
> !defined(IDENT2)
> 
> I've tried the following:
> version(!IDENT)
>  > identifier or integer expected, not !
> 
> !version(IDENT)
>  > Declaration expected, not '!'
> 
> version(IDENT || IDENT2)
>  > found '||' when expecting ')'
> 
> version(IDENT) || version(IDENT2)
>  > Declaration expected, not '||'
> 
> 
> This is just plain ugly:
> version(IDENT) {
> } else {
>    version = NOT_IDENT_OR_IDENT2;
> }
> 
> version(IDENT2) {
> } else {
>    version = NOT_IDENT_OR_IDENT2;
> }
> 
> version(NOT_IDENT_OR_IDENT2) {
>    // Finally
> }

Here's one nice solution to your problem:

http://www.digitalmars.com/d/archives/digitalmars/D/
Improving_version_..._119799.html#N119846

Basically, he defines an isVersion() template which is true if the 
current version is enabled, and false if not.

-Lars


More information about the Digitalmars-d-learn mailing list