The reason for SIGSEGV function pointer problem

Russel Winder via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 8 01:27:37 PDT 2017


Thanks also to Paolo Invernizzi and ag0aep6g for answering with a
similar response. Using Mike's response as it has extra detail.

On Wed, 2017-06-07 at 20:00 +0200, Mike Wey via Digitalmars-d-learn
wrote:
> On 06/07/2017 06:50 PM, Russel Winder via Digitalmars-d-learn wrote:
> > So why isn't &checkFrontend a thing of type check_frontend_t*
> 
> AFAIK, you would usually translate:
> 
> 
> typedef int (check_frontend_t*)(void *args, struct dvb_v5_fe_parms
> *parms);

The C code in dvb-scan.h is actually:

typedef int (check_frontend_t)(void *args, struct dvb_v5_fe_parms *parms);

> into:
> 
> alias check_frontend_t = extern(C) int function (void* args, 
> dvb_v5_fe_parms* parms);

I can't remember what DStep produced initially, but the above is what I
have in dvb_scan.d. Per se it seems consistent, but then functions in
D, and their signatures, may be totally different to functions in C.

> The problem there is that libdvdv5 defines it as (check_frontend_t)
> and 
> not (check_frontend_t*).
> To get around that you can ommit the * in the declaration of 
> dvb_scan_transponder, and then you should be able to pass
> &checkFrontend 
> to it.

I am now at the stage of wondering if I remember C semantics, C++
semantics, and D semantics for "pointers to functions".

There may also be an issue of there being a bug in DStep…

-- 
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20170608/8c9d6ab5/attachment.sig>


More information about the Digitalmars-d-learn mailing list