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



On Thu, 2009-03-26 at 18:13 +0000, Maciej Piechotka wrote:
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.


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+
    }
}

The exact syntax is not the main issue. The question is how to support
conditional compilation in such a way that we can keep the conditions in
the generated C code. Otherwise, we cannot support conditionals with
projects that distribute the generated C code in the source tarballs.

Jürg




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