Sig, I wonder whether that should be on by default. I have had some real frustrations with FFI of late, and something like this might have avoided the problem. Unless it is easily discoverable, off is almost the same as non-existent.
Any rumblings on Spock? It would be nice to have even a facade that unifies the FFI/NB/Alien on all platforms. It would indelicate to mention that this was supposed to happen in January<g>. I never really expected to see it that soon, given the problems I had going from 1.1.1 to 1.3 with FFI, and my rotating errors with Alien callbacks. I changed a bunch of FFI calls (in ways that I genuinely think should not have been necessary) and retreated to C functions for GSL callbacks. The latter is frustrating, BAD for my eventually being able to release a GSL binding (make that REALLY BAD), but not all bad because C++ is a better formula translator that Smalltalk, and the number crunching runs at native speeds. I think these things *can* work - they just don't at present, and the FFI/NB/Alien split makes it hard to know what to try. Bill ________________________________________ From: pharo-project-boun...@lists.gforge.inria.fr [pharo-project-boun...@lists.gforge.inria.fr] on behalf of Igor Stasenko [siguc...@gmail.com] Sent: Friday, April 20, 2012 10:46 AM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] [NativeBoost] Generic failure errors when using nil for void* and char* arguments On 20 April 2012 15:59, Jan van de Sandt <jvdsa...@gmail.com> wrote: > Hello, > > I use NativeBoost to call some icu4c functions. This works fine most of the > time. But now I run into the problem that when I pass nil as the argument > value for one or more void* / char* parameters I get an error. When I pass a > value or an empty ByteArray than it works. > > According to the icu4c documentation I should be able to pass NULL as an > argument value. > > What am I missing? > For pointers, there is an options in callouts, #optCoerceNilToNull which should be set, then you can invoke the call with nil as argument, which will convert it to C NULL. By default this option is OFF, because extra check means extra cycles. You can control a callout options by either per function call (see NBBasicExamples>>readDoubleFrom:) or for all methods of your class as a whole, like: MyClass class>>ffiCalloutOptions "by default, return all pointers as an instance of external address " ^ #( + optReturnPtrAsExternalAddress + optCoerceNilToNull "passing nil as pointer, will convert it to null(0) " ) > Jan. -- Best regards, Igor Stasenko.