On 0.3, try convert(Ptr{Ptr{Void}}, 0)
On Friday, October 9, 2015 at 4:03:51 AM UTC-7, Dominique Orban wrote:
>
> Thanks for the responses! No luck so far though:
>
> julia> akeep = Ptr{Ptr{Void}}(0)
> ERROR: type cannot be constructed
>
> I changed the signature of the ccall to Ptr{Ptr{Void}}, but declaring
> akeep=Ptr{Void} and passing &akeep yields: ERROR: `convert` has no method
> matching convert(::Type{Ptr{None}}, ::Type{Ptr{None}})
>
> Declaring akeep=Ptr{Ptr{Void}} and passing akeep directly yields: ERROR:
> `convert` has no method matching convert(::Type{Ptr{Ptr{None}}},
> ::Type{Ptr{Ptr{None}}})
>
> I don't understand what there is to convert. The two types mentioned in
> either error message are the same...
>
> Haven't tried 0.4 yet.
>
> @tkelman, I'll be very happy to release this when/if I can make it work.
>
> On Thursday, October 8, 2015 at 10:08:33 PM UTC-4, Isaiah wrote:
>>
>> akeep = Ptr{Void}
>>
>>
>> This is declaring a "DataType" variable (try `typeof(Ptr)` to see what I
>> mean). You need to construct an instance, so try: `akeep =
>> Ptr{Ptr{Void}}(0)`
>>
>> Then the ccall signature should be `(Ptr{Ptr{Void}},)`.
>>
>> (see also:
>> http://docs.julialang.org/en/release-0.3/manual/calling-c-and-fortran-code/#type-correspondences
>> )
>>
>> On Thu, Oct 8, 2015 at 9:36 PM, Dominique Orban <[email protected]>
>> wrote:
>>
>>> I'm trying to call the C interface to the HSL MA97 from Julia. It's a
>>> symmetric indefinite factorization library that uses OpenMP. One of the
>>> main C functions expects a void** as argument. The example that ships with
>>> the library declares a void* variable named akeep. The main program doesn't
>>> do anything with it except that it passes &akeep (i.e., a void**) to some
>>> of the library functions. Presumably, those functions allocate memory
>>> pointed to by akeep. It's a bit perplexing, but that's how it is. At the
>>> end, there's a call of the form free(&akeep).
>>>
>>> My question is: what syntax should I use in Julia to perform the same
>>> operations? Naively, I'm tempted to try something like
>>>
>>> akeep = Ptr{Void}
>>> ccall((:some_function, "libwhatever"), Void, (Ptr{Void},), akeep)
>>>
>>> but that returns the error message: `convert` has no method matching
>>> convert(::Type{Ptr{None}}, ::Type{Ptr{None}}).
>>>
>>> Replacing akeep with &akeep in the ccall returns: expected Ptr{None},
>>> got Type{Ptr{None}}.
>>>
>>> What might be the appropriate syntax here? And more importantly, is this
>>> a recipe for a segfault?'
>>>
>>> This is with Julia 0.3.11.
>>>
>>> Thanks!
>>>
>>
>>