Subject:
Re: [ruby-ffi] segfault on windows MRI but not windows JRuby
From:
Jon
Date:
11/28/09 2:03 PM
To:
ruby-ffi@googlegroups.com

> It could be the calling convention.  On JRuby, that isn't wired up
> yet, so it creates callbacks with C calling convention always, but on
> MRI, it is wired up, so it creates a callback with the convention as
> set by ffi_convention.

If it's not wired up in JRuby I'd also expect things to fail in JRuby as the example's callback prototype has CALLBACK which is defined as __stdcall in Windows.  Odd...JRuby's default __cdecl should cause problems.

Does ffi_convention set the calling convention for all attached fcn's of a module?  It appears to in lib/ffi/library.rb[64] but I haven't dug into any more of the code.


> Try setting ffi_convention to :default before declaring the callback,
> and then to :stdcall when declaring the functions exported by the
> library.

OK.  Will also try ffi_convention :stdcall before declaring the callback *and* before declaring the exported library fcns.

Jon