Re: [Vala] GTK_CHECK_VERSION in Vala
- From: Luc Chante <luc chante gmail com>
- To: rastersoft <raster rastersoft com>
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] GTK_CHECK_VERSION in Vala
- Date: Thu, 26 Apr 2018 06:13:18 +0000
Hi,
You can't, sorry.
Preprocessor in vala is simplistic, and doesn't intend to be more complex.
https://wiki.gnome.org/Projects/Vala/FAQ#Does_Vala_have_a_preprocessor.3F
But, you can define a symbol using valac command.
You will find plenty of examples to do it with autotools, for meson you can
get inspiration from the Gnome repository.
static int main(string[] args)
{
#if GTK_3_22
stdout.puts("GTK_3_22\n");
#else
stdout.puts("other\n");
#endif
return 0;
}
$ valac main.vala && ./main
others
$ valac -D GTK_3_22 main.vala && ./main
GTK_3_22
Or you can use vala code checking the actual version.
using Gtk;
static int main(string[] args)
{
stdout.printf("Gtk: %d.%d.%d\n", Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION,
Gtk.MICRO_VERSION);
return 0;
}
$ valac --pkg gtk+-3.0 main.vala && ./main
Gtk: 3.22.10
Hope I helped,
Luc.
Le mer. 25 avr. 2018 à 23:35, rastersoft <raster rastersoft com> a écrit :
Hello:
I want to do this conditional compilation in my code:
#ifGTK_CHECK_VERSION(3, 22, 0)
this.menu.popup_at_pointer(event);
#else
this.menu.popup(null, null, null, 2, Gtk.get_current_event_time());
#endif Unfortunately, GTK_CHECK_VERSION doesn't work in Vala. Is there
an alternative to do that in Vala? Thanks.
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]