valagtk4

Why Vala Compiler Throws Errors When Using Question Mark (?) Operator?


I tried to build G4Music (https://gitlab.gnome.org/neithern/g4music) following its instructions but I got many syntax errors. enter image description here

As you can see GTK-4.0 is marked as not found. However I have installed GTK-4.4 dev packages. I'm using RHEL 9 as distro and I have all the packages required:

I read that ? operator (question mark) is used to control null values and there's a lot of code using this operator. I have no experience with Vala language.

Do I missing some libraries? Why Vala compiler throw errors for this operator?

Thanks in advance


Solution

  • It looks like the null conditional operator was introduced in Vala 0.53.1, which was tagged 20 August 2021. That's a development release, so you want Vala 0.54+ installed to compile this.

    To learn more about the null conditional operator read the merge request and issue. Ideally the build system for g4music would check for the minimum version of the Vala compiler needed.