Re: [Vala] Conditional compilation



Hi Cayle,

On Die, 2007-02-13 at 15:41 -0600, Cayle Graumann wrote:
    Is it possible to do conditional compilation in vala similar to
using the C preprocessor #ifdef ?  I am at the stage of my program's
development where I have two different but similar sets of gui code
(one for the desktop using Cairo, and one for Nokia's Maemo which
doesn't have Cairo).  I'd rather not have and maintain separate sets
of vala files for each because that ends up with a lot of code
duplication, if I don't have to.

It's a known outstanding issue but no conditional compilation support
has been added yet. If you can't easily work around that limitation for
the moment, you can add a manual cpp invocation on .vala files to your
build system before you run valac, that should work fine.

I'd recommend to implement the two drawing code parts in subclasses or
to extract the drawing code into a separate class (with two different
implementations in two files) as it usually results in easier readable
code than many #ifdefs in one file. That shouldn't cause any code
duplication at all.

Jürg





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