If you never need to look at the fields of the struct, and the return value
is a pointer to the struct, you can declare the return type as Ptr{Void}.
For type safety, you might want to wrap the Ptr{Void} in a Julia immutable
immutable MyType
ptr::Ptr{Void}
end
function MyType(a::Integer, b::Integer)
MyType(ccall( (:com1, "pathToLib"), Ptr{Void}, (Int32, Int32),a ,b))
end
function draw(a::MyType)
MyType(ccall( (:draw, "pathToLib"), nothing, (Ptr{void}),a))
end
If you need to access the fields of the struct in Julia, you might have
success trying StrPack.
If myType is passed around by value (as the signature of draw indicates by
omitting the *), you have to find another solution.
Ivar
kl. 10:14:31 UTC+2 tirsdag 1. juli 2014 skrev [email protected] følgende:
>
> I am a newbee in Julia. I want to call a c function in Julia, but I have a
> problem.
> In C:
> function1:
>
> myType com1(int a, int b)
> {
> do some operator;
> return myType;
> }
>
> "myType" is a struct type that I define
>
> function2:
>
> void draw(myType a)
> {
> do some operator
> return ;
> }
>
> In Julia
> ccall( (:com1, "pathToLib"), ReturnedType, (Int32, Int32),a ,b)
> but "ReturnedType" should responsed to "myType", but julia do not have the
> type, what should I do? and how to pass the return value to function2?
>
>