C like macro is useful
downs
default_357-line at yahoo.de
Wed Jul 23 06:35:15 PDT 2008
davidl wrote:
> consider:
>
> version(v1)
> {
> enum e
> {
> a,
> b
> }
> }
> else
> {
> enum e
> {
> a,
> b,
> c
> }
> }
>
> If my enum contains a lot of stuffs.... D version becomes a disaster.
>
>
> consider:
> version(v1)
> {
> if ( cond1() && cond2() && a==b)
> {
> //blah
> }
> }
> else
> {
> if ( cond1() && cond2() && a!=b)
> {
> //blah
> }
> }
>
> in C you can do it
>
> if ( cond1() && cond2() &&
> #ifdef v1
> a==b
> #else
> a!=b
> #endif
> )
> {
> // blah
> }
>
>
> Any good and practical way to solve these?
>
>
>
>
version(v1) auto cond = a == b;
else auto cond = a != b;
What's the problem again?
More information about the Digitalmars-d
mailing list