If you redefine the struct as a julia immutable, you can unsafe_load() a pointer to that struct to read off the values in Julia. You can also use it to pass a pointer to the struct into C. This trick can take you quite a way without resorting to a C wrapper.
For one example, see: https://github.com/staticfloat/Nettle.jl/blob/master/src/hash.jl#L20-L28 https://github.com/staticfloat/Nettle.jl/blob/master/src/hash.jl#L41 On Sunday, 16 November 2014 15:10:07 UTC, Erik Schnetter wrote: > > I want to wrap a library (hwloc) for Julia. This is working fine. > > The library defines some C structs that are part of the API. My > current approach uses wrapper C functions to access struct elements. > Is there a better way? > > I thus I need to build this wrapper file as well. I created a > SimpleBuild rule for this. However, I need to know the path where > BinDeps installed (or found) the header files so that I can compile > this file. How do I access this information? > > -erik > > -- > Erik Schnetter <[email protected] <javascript:>> > http://www.perimeterinstitute.ca/personal/eschnetter/ >
