[Vala] how to call extern function expecting function pointer?
- From: Adam Dingle <adam medovina org>
- To: vala-list gnome org
- Subject: [Vala] how to call extern function expecting function pointer?
- Date: Tue, 09 Dec 2008 11:33:39 -0800
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 -
adam
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]