GNOME Bugzilla – Bug 487612
SQLite bindings generate callback with wrong signature
Last modified: 2007-11-09 05:00:08 UTC
Please describe the problem: The sqlite bindings declare the parameter signature for the callback function as: public static delegate int Callback (pointer data, int n_columns, string[] values, string[] column_names); and the original C callback is: static int callback(void *data, int n_columns, char **values, char **column_names); But the C code generated by valac is like this: static int callback(void *data, int n_columns, int values_length, char **values, int column_names_length, char **column_names); Note: may be not exactly like this, i'm far from my computer right now, but the idea is that string arrays generate 2 parameters, namely: "char **array" and "int array_length", which breaks the signature expected by the binded C library. Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information: I tried to use [NoArrayLength] in my callback declaration, but without success.
It was not a bug. To generate a callback function with the right signature I just have to use the NoArrayLength property in the correct manner: [NoArrayLength ()] public static int callback(pointer data, int n_columns, string[] values, string[] column_names) { (...) the lines above will generate the correct C function signature: gint demo_callback (gpointer data, gint n_columns, char** values, char** column_names) { (...)