2015-01-14 11:43 GMT+01:00 Tim Holy <tim.h...@gmail.com>:
> If you can, use
>
> immutable B
>     x::A
> end
>
> The "type" version contains a reference to an A, not the entire A structure
> itself. The C analog of what you were doing would be
>
> struct B {
>     A* x;
> };
>
> which of course doesn't have the same size as A.
>
> --Tim
>
> On Wednesday, January 14, 2015 02:22:19 AM Jan Niklas Hasse wrote:
>> Hi!
>>
>> I'm new to Julia and was wondering why
>>
>> type A
>>     x::Ptr{Void}
>>     y::Ptr{Void}
>> end
>>
>> type B
>>     x::A
>> end
>>
>> assert(sizeof(A) == sizeof(B))
>>
>> doesn't work while the C version
>>
>> #include <assert.h>
>>
>> struct A {
>>     void* x;
>>     void* y;
>> };
>>
>> struct B {
>>     A x;
>> };
>>
>> int main() {
>>     assert(sizeof(A) == sizeof(B));
>> }
>>
>> does? This causes a segfault in my FreeType.jl wrapper.

I see. Thanks to you both :)

Now I got it working:
https://github.com/jhasse/FreeType.jl/commit/2297d9c2c93c27466920acba46f9983dac882635

Reply via email to