@if-@else directive

@if-@else directives can be used for conditional macro expansion. Informally, the syntax is:


@if (b1) {x1}
@elseif (b2) {x2}
@elseif (b3) {x3}
...
@elseif (bn) {xn}
@else {y}

There may be zero or more @elseif directives. The @else directive is optional. The b1,...,bn are macro expanded before being evaluated as boolean valued expressions. This for example allows for nested @if-@else expressions, such as in the following example:

Before translationAfter translation
@def min(x,y) =
{
    @if(x < y) {x} @else {y}
}
int f() { return min(min(3,7),min(1,6)); }





int f() { return 1; }