Ah, thanks for this! Just yesterday I was trying to figure out how to pass
some pointers so they could be modified by a C function. This is a pretty
common idiom in lots of C code, maybe this little trick could be added to
the docs on C interop?

-s


On Sat, Dec 21, 2013 at 10:31 AM, Isaiah Norton <[email protected]>wrote:

> ```
>
> width = Cint[0]
>
> range = Cfloat[0]
>
> ccall(:foo, Void, (Ptr{Cint}, Ptr{Cfloat}), width, range)
>
> ```
>
>
> Explanation:
>
> - the first line declares an array with a single element of Cint (Int32) type
>
> - ccall automatically passes the address of the first (here, only) element of 
> the array when you request Ptr{Cint} / Ptr{Cfloat} in the type specification 
> tuple
>
>
>
> On Sat, Dec 21, 2013 at 10:15 AM, Andreas Lobinger <[email protected]>wrote:
>
>> Hello,
>>
>> i'm trying to use an external library for certain things and i need
>> somehow a 1:1 relation to certain input/output parameters:
>>
>> *float
>> *int
>>
>> I'm aware that the most promising thing is to do a type definition.
>>
>> Is
>>
>> type myiothing
>>  input::Array{Float32,1}
>>  output::Array{Int32,1}
>>  n_points:Int32
>> end
>>
>> the way to go, or is there something i'm missing (i have no clear
>> understanding, what Array{something,1} is creating only a pointer)?
>>
>> Wishing a happy day,
>>         Andreas
>>
>
>

Reply via email to