
On Jul 25, 2013, at 11:44 PM, Arshdeep Singh wrote:
Hi, I have been trying to write a function with a default argument.
The function: void recolor_wheel_nodes_init(GtkWidget *widget , int obj_list_size = RECOLOR_MAX_OBJECTS ) { ..... }
This gives the following error: expected ';', ',' or ')' before '=' token
Aren't default arguments allowed in GTK ? I bet I've seen them at a few places in the codebase before.
Default arguments go in the declaration, not definition of a function. I think this is the first issue you're hitting up against. (BTW, the "void" should not end up on a line by itself)
Next is that C++ allows for default arguments, but the GTK+ init functions do not. The GTK+ type system is pure C and has expectations as such. If you are expecting to use this as a GTK+ init function, the the GTK+ system probably will not use the default.
At compile time, what happens is that the compiler acts as if you explicitly had typed recolor_wheel_nodes_init(widget, RECOLOR_MAX_OBJECTS);