A friend pointed out to me lately that Vala can produce C code with clashing symbols. True, and I knew it was possible, but there is a solution. First however, the problem:
public class prefix {
public static int other_name;
}
public class prefix_other {
public static int name;
}
int main() {
prefix.other_name = 1;
prefix_other.name = 2;
return 0;
}
And the solution:
public class prefix {
[CCode(cname = "prefix_other_name2")]
public static int other_name;
}
public class prefix_other {
public static int name;
}
int main() {
prefix.other_name = 1;
prefix_other.name = 2;
return 0;
}
Now that may seem like a hack, but that’s OK. Please remember that the stated goal of Vala is to bring the benefits of a modern programming language to GLib, whilst keeping compatibility (paraphrased). GLib is C based, with naming conventions, and coding standards that must be followed. So it follows that Vala must follow them, right down to the mechanisms for choosing variable names.

