Re: [Vala] Define constant at compile time



Hello, your solution is nice and works. I still would like to see a
better Vala preprocessor sometime in the future, but the CCode decorator
looks *really* interesting. Thank you for having pointed it out.

On Tue, 2010-11-16 at 19:08 +0100, Jan Hudec wrote: 
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\" ...


-- 
Andrea Corbellini
Ubuntu Member  | http://www.ubuntu.com
BeeSeek Member | http://www.beeseek.org

Attachment: signature.asc
Description: This is a digitally signed message part



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