sn-bindgen
sn-bindgen copied to clipboard
Cases where C wrappers are needed
The goal of the issue is to list cases where SN might have troubles to bind some C definitions, and where C wrappers are required as workarounds.
List of possible issues:
- variadic functions and functions accepting a va_list argument
- global constants
- global variables
Regarding globals several issues can be considered:
- globals are not always exported, this is particularly the case on Windows, depending on the compiler (and compiler configuration) which was used to generate the DLL
- a non-constant global will be defined in the Scala Native
extern valwith its initial value only - SN doesn't support passing structs by value
- char[] vs char*: SN can currently deal with constant strings defined as char* but not with char[]
Workarounds:
- for each global variable, create a C getter, this should allow to bypass the different mentioned issues
- convert char[] into char*
- return global structs using a pointer provided to the C getter