The reason for SIGSEGV function pointer problem
Russel Winder via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 7 09:50:26 PDT 2017
OK, so I have narrowed down my SIGSEGV problem to having no real idea
how to do C function pointers in D code.
So I have a callback function that will be called from C library code.
It currently has signature:
extern(C) int checkFrontend(void* _arguments, dvb_v5_fe_parms* frontendParameters)
because of the extern(C) I believe you have to use a type alias in
order to specify the type in function definitions. Hence:
alias check_frontend_t = extern(C) int function (void* args, dvb_v5_fe_parms* parms);
In the constructor of an object to abstract the result of a call to the
C library code, the parameter is:
check_frontend_t* cf
in the creation of the object using the constructor, I am using the
argument:
&checkFrontend
However. This gives me a type error:
extern (C) int function(void*, dvb_v5_fe_parms*)* cf
is not callable using argument type:
extern (C) int function(void*, dvb_v5_fe_parms*)
all the other arguments/parameters types match exactly, this is the
only difference.
So why isn't &checkFrontend a thing of type check_frontend_t*?
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
More information about the Digitalmars-d-learn
mailing list