Valac: Compiling into C code: Expected semicolon in the wrong place
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 { |
Shouldn't there be a semicolon at the end of the nested classes too ?
|
Yeah, inserting semicolons at the end of the nested classes causes more errors. This is Vala we're talking about here, the programming language written for the GNOME project that uses GLib as the standard library, has a syntax very much like Java's and C#'s, and compiles to C. You must have mistaken it for Java; that happens often.
|
Besides, Anisha: Here's the whole point of this post.
Notice the comments in my code pointing you to the location of the "error"? Scroll to the bottom of the code block, and you'll find them, as well as an upward-pointing carat pointing you to the location of just WHERE the compiler is telling me to insert the semicolon (Hint: It's in an odd location). |
Well yes I mistook it for C++ :doh: and I am sorry for taking your thread off the zero reply list !
I saw your bolded code text earlier and the reason I pointed to the class semicolons was that compiler often points out to the wrong place w.r.t semicolons in C/C++ ! Check whether the functions are supposed to be called the way you have called them ? I know you must have already seen this page: http://www.linux.com/archive/feature/154784 and you can report my post for deletion in order to keep your thread in the zero reply list ! |
Sometimes errors propagate through to give unusual error messages.
So do you need to have semi-colons to end the nested classes? If so put them there and then check and fix the new error messages that appear. Completely unrelated to your compiler errors but I don't think that the following does what you want it to do. Code:
r = red; |
Another point I don't think that your outer class knows about the identifiers red, green or blue.
Again unrelated to the compiler errors but you will probably have a hard time distinguishing the difference between the fg_color and bg_color, they are almost identical. |
The following functions are constructors:
Code:
... Code:
Gtk.rgba.bg_color foo(17, 17, 17); Code:
Gtk.rgba.bg_color foo(17, 17, 17); |
Quote:
|
These are the errors I get when I put semicolons at the end of the nested classes:
Code:
kenny_strawn@kenny-AOA110:~/Documents$ valac --pkg=gtk+-2.0 gtk_rgba.vala -H gtk_rgba.h |
Code:
//Here's where the error is |
Those are initializations of the bg_color and fg_color classes, as declared before the functions (in turn within a function definition):
Code:
... While the alpha value is between 0 and 1 and increments, the foreground color is supposed to increment and the background color decrement. This is literally what drives alpha blending: the background (at a lower alpha value) is supposed to blend into the foreground. This is how you get the look of partially transparent colors. |
anishakaul My interpretation is that the bold values are object of type fg_color and bg_color respectively.
Kenny_Straw As I read the code red, green and blue are properties of the inner classes and not visible at the outer class level. That is what the compiler is complaining about and importantly this occurs on the line prior to the one you had indicated. Which means that the compiler message does make some sense. |
I'd like to emphasis the point I gave earlier.
Code:
r = red; |
I had missed post 8 *sigh*
Oh yes, it should be the other way round, now I do notice it too.. red = r; green = g; blue = b; Quote:
http://publib.boulder.ibm.com/infoce...%2Fcplr061.htm |
All times are GMT -5. The time now is 07:05 PM. |