-
Hi! I'm trying to generate bindings for sqlite3. Using The header is SQLITE_API int sqlite3_open(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb /* OUT: SQLite db handle */
); (I've confirmed that the signature is the same on both ARM mac and ARM Linux) On an ARM mac or x86 linux, I'm getting: /**
* [bindgen] header: (truncated)/include/sqlite3.h
*/
def sqlite3_open(filename : CString, ppDb : Ptr[Ptr[sqlite3]]): CInt = extern but on ARM Linux, it's: /**
* [bindgen] header: (truncated)/include/sqlite3.h
*/
def sqlite3_open(filename : Ptr[CUnsignedChar], ppDb : Ptr[Ptr[sqlite3]]): CInt = extern so clearly Cheatsheet:
Am I doing something wrong, or could this be an issue in sn-bingen? Note: I'm using the sn-bingen binary from the Nix flake. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've seen this before. Bindgen by itself does not have platform specific code, it uses libclang for introspection of numeric types. Seems like on all platforms I test on apart from arm64 linux, the implementation of what "char" means is a signed char. The standard though doesn't specify what To enforce one way or another, you can use I recommend using Confirmed in an arm64 VM: $ bin/bindgen --header test.h --package sqlite --scala --clang -fsigned-char
package sqlite
import _root_.scala.scalanative.unsafe.*
import _root_.scala.scalanative.unsigned.*
import _root_.scala.scalanative.libc.*
import _root_.scala.scalanative.*
@extern
private[sqlite] object extern_functions:
/**
* [bindgen] header: test.h
*/
def sqlite3_open(filename : CString): CInt = extern
object functions:
import extern_functions.*
export extern_functions.*
object all:
export _root_.sqlite.functions.sqlite3_open |
Beta Was this translation helpful? Give feedback.
I've seen this before.
Bindgen by itself does not have platform specific code, it uses libclang for introspection of numeric types.
Seems like on all platforms I test on apart from arm64 linux, the implementation of what "char" means is a signed char.
The standard though doesn't specify what
char
means (words on SO, I didn't bother to verify: https://stackoverflow.com/a/2054941).To enforce one way or another, you can use
-fsigned-char
or-funsigned-char
in clang flags passed to bindgen.I recommend using
-fsigned-char
as it will useCString
in the bindings.Confirmed in an arm64 VM: