sn-bindgen icon indicating copy to clipboard operation
sn-bindgen copied to clipboard

Cases where C wrappers are needed

Open david-bouyssie opened this issue 3 years ago • 0 comments

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 val with 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

david-bouyssie avatar Jan 05 '22 10:01 david-bouyssie