[plt-scheme] foreign: am I missing something basic?
Hm, I don't know. I've written DLL's in Visual Studio for use with
scheme/foreign before, and never had these problems. However, I don't
think I ever passed arbitrary Scheme objects; the API's I used were
just passing simple primitives that scheme/foreign translates
automatically to corresponding C types. I suppose it's possible I've
been building the DLL's wrong all along. But I'm not sure what I would
need to change to fix such an issue.
Just a couple more data points:
* I made sure the program is being compiled as C and not C++, but to
be sure I added a __cdecl modifier to the function declaration, with
no difference in behavior.
* I have tried debugging the crashed DLL in Visual Studio, and it's
showing the value of the pointer x as the very suspicious value 0x95;
the crash is an access violation (can't read from that protected
address).
* The syntax object doesn't seem to be the main culprit; when I pass a
pair to peek-inside, the value of x is 0x65 and again the DLL crashes
with an access violation.
Dave
On Sep 27, 2009, at 7:59 AM, Noel Welsh wrote:
> On Thu, Sep 24, 2009 at 3:15 AM, Dave Herman <dherman at ccs.neu.edu>
> wrote:
>> (define peek-inside
>> (get-ffi-obj 'peek_inside lib (_cprocedure (list _scheme)
>> _short)))
>
> An idiomatic definition would be:
>
> (_fun _scheme -> _short)
>
> instead of your _cprocedure definition.
>
> Perhaps the issue is one of calling conventions? I know Windows uses
> the "Pascal" (stdcall?) calling convention for it's libraries. Perhaps
> shared libraries are automatically defined with this convention?
>
> N.