[Vala] Bug in vala compiler ? Add NULL argument to an extern function



Hello, I've got a compilation problem with vala during the generation of 
the C code.

In the C code, vala add a new argument in an extern function :


$ valac monitor.vala libftw.vapi 
/home/sebastien/sync/fam/err/monitor.vala.c: In function ‘monitor_run’:
/home/sebastien/sync/fam/err/monitor.vala.c:51: warning: passing argument 
3 of ‘ftw’ makes integer from pointer without a cast
/usr/include/ftw.h:137: note: expected ‘int’ but argument is of type 
‘void 
*’
/home/sebastien/sync/fam/err/monitor.vala.c:51: error: too many arguments 
to function ‘ftw’
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

Here is the line in the C file :

ftw ("path", (__ftw_func_t) monitor_list_file, NULL, 1);
                                               ^^^^^
                                               wtf ?

What does the NULL here ? It seems a bug in the compiler but maybe I'm 
wrong in the delegate declaration…


Here is the vala file : monitor.vala
using GLib;
using FTW;

public class Monitor:GLib.Object {


    public int run() {
            FTW.ftw("path", (FTW.ftw_func_t)list_file, 1);
            return 0;
        }

    public static int list_file(string name, int* status, int type) {
        if (type !=1 )
            return 0;
        return 0;
    }

}
public static int main(string[] args) {
    Monitor monit = new Monitor();
    monit.run();
    return 0;
}

and the vapi : libftw.vapi
[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = 
"ftw.h")]
namespace FTW {

    [CCode (cname = "__ftw_func_t")]
    public delegate int ftw_func_t(char* name, int* status, int type);

    [CCode (cname = "ftw")]
    public void ftw(char *path, ftw_func_t fn, int nbdir);
}

I'm using valac 0.8.1 on debian.

Thank you !

-- 
Sébastien





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