Re: [Vala] Conditional compilation: Passing #ifdefs through to generated C code
- From: Jürg Billeter <j bitron ch>
- To: Michael Terry <mike mterry name>
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] Conditional compilation: Passing #ifdefs through to generated C code
- Date: Tue, 24 Mar 2009 14:20:19 +0100
On Mon, 2009-03-23 at 20:35 -0400, Michael Terry wrote:
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.
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]