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



I'd like to know more about how to use C preprocessor commands in
Vala.  I know that Vala allows some sort of conditional compilation
via [Conditional], but I'm interested in a particular use case that it
doesn't seem to really help with.

Specifically, I have a GTK+ app, and I want to use a bit of code only
if the compile-time GTK+ version is high enough.  So something like:

#if GTK_CHECK_VERSION(2, 4, 0)
   GtkFileChooserAction action;
   ...
#endif

I can have vala conditionally use a bit of code, but the conditional
is resolved at Vala-compile-time, not C-compile-time.  I need
'passthrough' conditionals that show up in the generated C code, since
my software distributes the C code in the release tarball.  The
typical user just compiles the C.

2 suggestions:
1) Isolate the conditional code in a C glue file.
2) Use the build system to resolve the condition. (e.g. Automake conditionals)


-- 
http://homes.eff.org/~barlow/EconomyOfIdeas.html
http://www.dreamsongs.com/MobSoftware.html
http://www.gnu.org/philosophy/shouldbefree.html



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