Valac: Compiling into C code: Expected semicolon in the wrong place
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Here is my problem: I have a Vala program that includes classes with nested classes. When I try to initialize classes (using the variable type and the variable, followed by the class's arguments [three unsigned 8-bit integers] in parentheses) and try to compile the Vala code to C code (thanks Steshenko, that's what I tried to AVOID doing, as I really wanted to create a shared object file, but now I know I have to use C code as a middleman), the compiler tells me it expects a semicolon between the class variable name and its members.
What?! A semicolon in a bad place, that's for sure! Why would I want to put a semicolon *BETWEEN* the class initialization and its members? Isn't the whole point of a class to *HAVE* different members?
Here is my class:
Code:
public class Gtk.rgba : GLib.Object {
public class fg_color : GLib.Object {
private uint8 red;
private uint8 green;
private uint8 blue;
//Constructor
public fg_color(uint8 r, uint8 g, uint8 b) {
r = red;
g = green;
b = blue;
uint full_color = red * green * blue;
}
}
public class bg_color : GLib.Object {
private uint8 red;
private uint8 green;
private uint8 blue;
//Constructor
public bg_color(uint8 r, uint8 g, uint8 b) {
r = red;
g = green;
b = blue;
uint full_color = red * green * blue;
}
}
//Toplevel constructor
public rgba(var bg, var fg) {
bg = bg_color;
fg = fg_color;
}
public static void init(double alpha) {
double alpha_t = alpha;
//Here's where the error is
for (alpha_t > 0; alpha_t < 1; ++alpha_t) {
fg_color fg_increment(red++, green++, blue++);
bg_color bg_decrement(red--, green--, blue--);
^ //The compiler is telling me to put a semicolon *HERE* <yawn>.
}
}
}
Prove that the compiler is wrong. I.e. take the language spec/standard, read it, show the relevant paragraphs and prove that the compiler is incompatible with the language spec/standard.
Had it been "C", I would have said "read the C99 standard". Notice, that the languages you are trying to use change, but your problems stay the say. The main problem typically is: expectations based on nothing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.