4 ms·
I might be revealing myself as a novice rust programmer here, but can't you use 'ptr : * const()' as an opaque pointer type? It's how I interface with C and C+
by SCHiM 7y ago
I might be revealing myself as a novice rust programmer here, but can't you use 'ptr : * const()' as an opaque pointer type?
It's how I interface with C and C++ callback functions.
- steveklabnik 7y agoYou can, but there’s reasons a real external type feature is useful: https://github.com/rust-lang/rfcs/blob/master/text/1861-extern-types.md https://github.com/rust-lang/rfcs/blob/master/text/1861-exte...
- ChrisSD 7y agoAccording to the nomicon[0], using a zero sized array in a repr(C) struct is the best practice for type safety. I also seem to remember someone saying the zero sized array is analogous to how LLVM bitcode represents void* in C. [0] https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs https://doc.rust-lang.org/nomicon/ffi.html#representing-opaq...