Re: [Vala] Conditional compilation: Passing #ifdefs through to generated C code



Jürg Billeter <j <at> bitron.ch> writes:

I understand the issue. Unfortunately, it's not easy to solve. One issue
is that you might need multiple #if in the generated code for a single
#if in the Vala code - e.g. for #include directives. It would also
require the Vala compiler to support dealing with multiple declarations
of the same method for different conditions, which would make semantic
and flow analysis a lot more difficult.

I'd be happy to hear proposals how we could solve this in a
non-intrusive way.

Jürg


May be static if or something like that?

void my_method () {
    [StaticIf]
    if (vala.pkg.gtk+-2.0.version > 2.4.0") {
        // Use new gtk+
    } else {
        // Use legacy gtk+
    }
}

Version can be simply get from pkg-config.

Regards





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]