[Vala] how to call extern function expecting function pointer?

I'm trying to call the C library function qsort() from Vala. I tried this:

delegate int CompareFunc (void* a, void* b);
extern void qsort(void *base, size_t count, size_t size, CompareFunc f);

Vala accepts that, but then C compilation fails with the following:

top.c:41: error: conflicting types for ‘qsort’
/usr/include/stdlib.h:689: error: previous declaration of ‘qsort’ was here

Vala has generated the following C declaration with 5 parameters:

static void qsort (void* base, gsize count, gsize size, CompareFunc f, void* f_target);

But the C library's declaration has only 4 parameters:

extern void qsort (void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar)

So: is there some attribute I can apply to the extern declaration that will cause Vala to generate a compatible function prototype? Or should I instead write some C code to wrap qsort() into a C function which Vala can call more easily? Thanks for any advice -


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