[Cffi-devel] possible cffi bug
Willem Rein Oudshoorn
woudshoo at xs4all.nl
Mon Apr 14 05:23:30 UTC 2014
Joeish W <joeish80829 at yahoo.com> writes:
> I have these 2 wrappers for the C++ vector class and I wrap both in CFFI the same way, and call them
> the same way but I'm getting unhandled memory fault errors when using
> my wrapper for the carraytovectorm, The only difference being, using
> the carraytovectorp as an example of all my other carraytovector type
> c wrappers that are written the same way, is that when I initialize
> the Point class to pass to the carraytovectorp I can do it like this:
>
> Point* m, n, o;
> vector_Point* v = std_carrayTovectorp(m, 3);
This is very odd, you define 3 variables, m, n and o. But they are of
different type:
m - pointer to point
n and o - are point
Secondly, you assume that they form a c-array of 3 elements. However
you only defined 3 separate variables, not a c-array.
So the fact that it does not crash is luck.
You ran out of luck in your second version.
Wim Oudshoorn.
More information about the cffi-devel
mailing list