|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.learn - Calling C functions with D function pointers as operands
How can I call C functions with D function pointers as operands? I tried this: // gl2psUserWritePNG & gl2psUserFlushPNG are static void function(png_struct*, ubyte*, uint) gl2psUserWritePNG_ptr = &gl2psUserWritePNG; void function(png_struct*) gl2psUserFlushPNG_ptr = &gl2psUserFlushPNG; png_set_write_fn( png_ptr, cast(void*)png, gl2psUserFlushPNG_ptr, gl2psUserFlushPNG_ptr ); but there are some errors: Error: cannot implicitly convert expression (gl2psUserWritePNG_ptr) of type void function(png_struct*, ubyte*, uint) to voidC function (png_struct*, ubyte*, uint) Error: cannot implicitly convert expression (gl2psUserFlushPNG_ptr) of type void function(png_struct*) to voidC function(png_struct*) Apr 26 2008
"Zarathustra" <adam.chrapkowski gmail.com> wrote in message news:fuvj7c$1hf7$1 digitalmars.com...How can I call C functions with D function pointers as operands? I tried this: // gl2psUserWritePNG & gl2psUserFlushPNG are static void function(png_struct*, ubyte*, uint) gl2psUserWritePNG_ptr = &gl2psUserWritePNG; void function(png_struct*) gl2psUserFlushPNG_ptr = &gl2psUserFlushPNG; png_set_write_fn( png_ptr, cast(void*)png, gl2psUserFlushPNG_ptr, gl2psUserFlushPNG_ptr ); but there are some errors: Error: cannot implicitly convert expression (gl2psUserWritePNG_ptr) of type void function(png_struct*, ubyte*, uint) to voidC function (png_struct*, ubyte*, uint) Error: cannot implicitly convert expression (gl2psUserFlushPNG_ptr) of type void function(png_struct*) to voidC function(png_struct*) Apr 26 2008
|