Re: [Vala] Question about valac symbols (-D, --define)
- From: Enrique Ocaña González <eocanha igalia com>
- To: vala-list gnome org
- Subject: Re: [Vala] Question about valac symbols (-D, --define)
- Date: Thu, 7 Oct 2010 13:52:02 +0200
On Thursday 07 October 2010 12:40:15 Tomasz Jankowski wrote:
I'm new to Vala. I already integrated it with my project (I use Autotools).
I have problem with defining preprocessor symbol, I want to do something
like this:
gcc -DDATA_DIRECTORY_PATH="../data" main.c -o app
The alternative I found to do that kind of things is to create a custom vapi
file, such as:
[CCode (cprefix = "", lower_case_cprefix = "")]
namespace Config {
public const string DATADIR;
...
}
Use it in your program like this:
using Config;
...
const string UI_PATH = Config.DATADIR+"/myapp/ui";
And compile the program in two stages (Vala to C, C to executable), more or
less like this (taken from a Makefile.am):
valac -C --vapidir=. --pkg=config [...] program.vala
gcc -DDATADIR=\""$(datadir)"\" [...] program.c
With the vapi, Vala just expects the defined string "to be there" and "to be
of the proper type". Then you supply it via gcc parameter or via an
additionally included C header.
Cheers.
--
Enrique Ocaña
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]