www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Conditional Compilation, Version Condition

reply "Artem Rebrov" <ar_other mail.ru> writes:
I found that no elegant way to express in D somthing like this:

#if(VerA>=4)
  // do somethig
#endif

#if(VerA>=3)
  // do somethig
#endif

#if(VerB>=2)
  // do somethig
#endif

I can write:

version(VerA_4)
{ version=VerA_3;  version=VerA_2;}
version(VerA_3)
{ version=VerA_2;}
version(VerB_4)
{ version=VerB_3;  version=VerB_2;}
version(VerB_3)
{ version=VerB_2;}
version(VerA_4)
{/*do somethig*/}
version(VerA_3)
{/*do somethig*/}
version(VerB_2)
{/*do somethig*/}

But what will be if I need VerA_10?

I think it is possible to introduce somthing like this:

version=VerA,4;
version(VerA,4)
{
  /*do somethig*/
}

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Oct 20 2005
parent reply "Artem Rebrov" <ar_other mail.ru> writes:
The other way to reach the same result is to write static if in global  
scope.
Do somebody have any ideas about it?

On Thu, 20 Oct 2005 23:20:50 +0400, Artem Rebrov <ar_other mail.ru> wrote:
 I found that no elegant way to express in D somthing like this:

 #if(VerA>=4)
   // do somethig
 #endif

 #if(VerA>=3)
   // do somethig
 #endif

 #if(VerB>=2)
   // do somethig
 #endif

-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Oct 24 2005
parent reply Dan <Dan_member pathlink.com> writes:
I think you can do this:

version(v5)
{
bla
}
else version(v4)
{
bla
}
else version(v3)
{
bla
}

Does that suit ya?
Oct 25 2005
parent "Artem Rebrov" <ar_other mail.ru> writes:
On Wed, 26 Oct 2005 03:42:00 +0400, Dan <Dan_member pathlink.com> wrote:

 I think you can do this:

 version(v5)
 {
 bla
 }
 else version(v4)
 {
 bla
 }
 else version(v3)
 {
 bla
 }

 Does that suit ya?

In this case I must write something like this: version(v5) { int k; int j; int i; } else version(v4) { int j; int i; } else version(v3) { int i; } -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Oct 30 2005