strpack.jl
is deprecated. Use the StrPack
package or Julia's native C struct interop instead, depending on your needs.
This gist demonstrates calling C code which expects a structure pointer by writing and reading a buffer using the functions provided by strpack.jl
. This takes advantage of the new align_native
alignment strategy, which queries libLLVM for the platform-preferred alignment of the standard bits types.
gcc -Wall -fPIC -c *.c
cc -shared -Wl,-soname,libtest.so -o libtest.so *.o
julia> load("struct_test.jl")
julia> foo
Foo(1,4.0,0x07)
julia> foo2
Foo(2,11.0,0x06)