Ifdef macro

Is it possible to create a macro that’s equivalent to an ifdef?

class C {
    @if(feature) var foo = 0
}

To mean the same as:

class C {
    #if feature
    var foo = 0
    #endif
}

Ideally with an ability to apply it to statements as well:

@if(feature)
if condition {
    …
} else {
    …
}

<—>

#if feature
if condition {
    …
} else {
    …
}
#endif