Interfacing with C++
Mike Parker
aldacron at gmail.com
Sun Feb 4 08:33:20 UTC 2018
On Sunday, 4 February 2018 at 08:17:31 UTC, Mike Parker wrote:
>
> So assuming CV_CDECL is cdecl, this should do it:
>
> extern(C) alias CvCmpFunc = int function(const(void)*,
> const(void)*, void*);
Assuming this is OpenCV, Looking at [1], it's cdecl only on
Windows. Empty everywhere else. So since OpenCV is a C++ library
these days, I guess it needs to be declared like this:
version(Windows)
extern(C) alias CvCmpFunc = int function(const(void)*,
const(void)*, void*);
else
extern(C++) alias CvCmpFunc = int function(const(void)*,
const(void)*, void*);
Though, I'm curious why anyone would want to declare a callback
in a C++ program as cdecl only on Windows and use the default C++
convention everywhere else. I suggest you dig into it and make
sure that's what's intended. And good luck binding to OpenCV!
[1]
https://github.com/opencv/opencv/blob/master/modules/core/include/opencv2/core/types_c.h#L68
More information about the Digitalmars-d-learn
mailing list