Compile-time option for a string in Vala

I’m writing a networked application and I need to add a compile-time option (e.g. in meson.options) for the address of the server. How do I do this? From what I’ve gathered only boolean (i.e. #ifdef, etc.) macros are supported.

You can do the usual thing of generating a header file and then manually “bind” that variable in your code with

[CCode (cname="MY_CONSTANT_NAME")]
extern string adddress;

(from memories)

How would I do that with meson? I’m kinda new to meson.

So what I do is use configure_file (Configuration) from meson and a custom vapi to bind those defines (src/librygel-core/rygel-build-config.vapi · master · GNOME / rygel · GitLab)

1 Like