On Tue, Nov 16, 2010 at 18:36:07 +0100, Andrea Corbellini wrote:
> I want to specify the constant UI_FILE at compile time, but I don't know
> how to do that. In C I would write something like that:
>
> #ifndef UI_FILE
> #define UI_FILE "default-path.xml"
> #endif
>
> and then I would call gcc with the option -DUI_FILE="something". I've
> tried to use the -D option of the Vala compiler, but it doesn't seem to
> work as I expect. Any ideas?
There are two ways:
1. Define it as
static const string UI_FILE = "@ui_file@"
in a .vala file and have it substituted by autoconf (similar mechanizm
exists in any other build tool as well).
2. Define it as
[CCode(cname="UI_FILE" cheader_filename="defaults.h")]
extern const string UI_FILE;
in a .vala file (or in a .vapi file in which case it's extern
implicitly), put the defines you cited above in this "defaults.h" file
and optionally pass the -D option to the C compiler. You can pass options
through vala to the C compiler by prefixing them with -X like:
vala ... -X -DUI_FILE=\"something\" ...
--
Jan 'Bulb' Hudec <[email protected]>
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list