[Haskell-cafe] global variables for foreign C functions
Andrea Rossato
mailing_list at istitutocolli.org
Mon Dec 1 19:39:25 EST 2008
Hello,
I'm writing the bindings to a C library which uses, in some functions,
global variables.
To make it clearer, those functions need a global variable to be
defined. A C program using my_function, one of the library functions,
would look like:
char progname[] = "a_program_name";
int
main( int argc, char *argv[] )
{
param p;
my_function ( &p )
etc.
I've been searching the ML, the wiki, the net, etc. without finding
some examples on how such things are dealt with in Haskell - is it
possible, BTW?
If I import those functions without defining the global variable I get
a linker error:
/usr/lib/mylib.a(cfile.o): In function `my_function':
cfile.c:(.text+0x510): undefined reference to `progname'
I hope the issue is clear. Any help would be greatly appreciated.
Andrea
More information about the Haskell-Cafe
mailing list