Re: Set maximum length for text control

Check that your callback looks similar to the following.

It looks like you have "gint WXUNUSED(len), gpointer *user_data" that is likely giving you trouble.

A couple of notes about this. It is a good idea to look up the callback in the documentation. If you get the parameters wrong your code may compile without warning and then later segfault. This is something in C you have to be careful of. The compiler might not help you here. Also a gpointer is a void* pointer.

This can cause confusion. When you are using a gpointer *user_data, that is a pointer to an array of pointers like a void **user_data or a void *user_data[]. That is valid if you are sending to your callback a pointer to some array of pointers and you might want to do this. Again, the compiler might not be able to help you when using void* pointers and you will probably get a segfault if you get it wrong. The documentation has a gpointer user_data parameter so that you can pass a pointer of any type to your callback along with the other required callback parameters. If you know the type of the pointer you can use the type in the callback so the compiler can help find potential errors. If you are sending a GRand* to your callback you can type it as such. If you are sending a pointer to an array of widget pointers you might have something like GtkWidget **widgets or GtkWidget *widgets[] although gpointer *widgets will work also and is valid but the compiler can't type check it for you.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]