Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Ticket #4 (new defect)

Opened 13 years ago

extern (C) not declared for C function pointers

Reported by: e-t172 Assigned to:
Priority: major Keywords:
Cc:

Description

The problem appears when using BCD generated bindings implicating C function pointers, for instance the MySQL C client library. This is incorrect :

alias int function(void * *, char *, void *) _BCD_func__969;
alias int function(void *, char *, uint) _BCD_func__970;
alias void function(void *) _BCD_func__971;
extern (C) void mysql_set_local_infile_handler(st_mysql *, _BCD_func__969, _BCD_func__970, _BCD_func__971, _BCD_func__970, void *);

This works :

extern (C) alias int function(void * *, char *, void *) _BCD_func__969;
extern (C) alias int function(void *, char *, uint) _BCD_func__970;
extern (C) alias void function(void *) _BCD_func__971;
extern (C) void mysql_set_local_infile_handler(st_mysql *, _BCD_func__969, _BCD_func__970, _BCD_func__971, _BCD_func__970, void *);

The incorrect code compiles if you pass pointers to D functions that are not declared with extern (C) though, which makes the problem even worse, because in this case the callback arguments are unusable but you can only see it at runtime.