|
1 | 1 | # Limitations
|
2 | 2 |
|
3 |
| -There are multiple unsupported cases that should be considered when generating bindings: |
4 |
| - |
5 |
| - 1. Currently bindgen does not support passing structs by value. |
6 |
| - For example, it will not be possible to call these two functions from Scala Native code: |
7 |
| - |
8 |
| - ```c |
9 |
| - struct MyStruct { |
10 |
| - int a; |
11 |
| - }; |
12 |
| - |
13 |
| - struct MyStruct returnStruct(); |
14 |
| - |
15 |
| - void handleStruct(struct MyStruct mystr); |
16 |
| - ``` |
17 |
| - To support such cases one should generate bindings for C wrapper functions that use pointers to structs instead of actual structs. |
18 |
| - 2. `#define`s for literals and variables are supported. For other types of `#define`s, |
19 |
| - write wrapper functions that return defined values. |
20 |
| - |
21 |
| - ```c |
22 |
| - // Supported |
23 |
| - #define ESC 0x1b /* Defines for numerical and string literals. */ |
24 |
| - extern const int pi_const; |
25 |
| - #define PI pi_const /* Defines aliasing extern variables. */ |
26 |
| - |
27 |
| - // Not supported (non-exhaustive list) |
28 |
| - #define COLS (getenv("COLS") ? atoi(getenv("COLS")) : 80) |
29 |
| - #define MAX(a, b) (a > b ? a : b) |
30 |
| - ``` |
31 |
| - |
32 |
| - 3. There is no way to reuse already generated bindings. |
33 |
| - Bindgen outputs bindings also for headers that were included in a given header. See @github[#2](#2). |
34 |
| - 4. Type qualifiers `const`, `volatile` and `restrict` are not supported. |
35 |
| - 5. Extern variables are read-only. See @github[scala-native/scala-native#202](scala-native/scala-native#202). |
| 3 | +There are multiple unsupported cases that should be considered when generating bindings. |
| 4 | + |
| 5 | +## Passing structs by value |
| 6 | + |
| 7 | +Scala Native does not support passing structs by value, bindgen skips such functions. |
| 8 | +```c |
| 9 | +struct MyStruct { |
| 10 | + int a; |
| 11 | +}; |
| 12 | + |
| 13 | +struct MyStruct returnStruct(); // skipped |
| 14 | + |
| 15 | +void handleStruct(struct MyStruct mystr); // skipped |
| 16 | +``` |
| 17 | +To support such cases one should generate bindings for C wrapper functions that use pointers to structs instead of |
| 18 | +actual structs. |
| 19 | +
|
| 20 | +## Limited support of `#define`s |
| 21 | +
|
| 22 | +`#define`s for literals and variables are supported. For other types of `#define`s, |
| 23 | +write wrapper functions that return defined values. |
| 24 | +
|
| 25 | +```c |
| 26 | +// Supported |
| 27 | +#define ESC 0x1b /* Defines for numerical and string literals. */ |
| 28 | +extern const int pi_const; |
| 29 | +#define PI pi_const /* Defines aliasing extern variables. */ |
| 30 | +
|
| 31 | +// Not supported (non-exhaustive list) |
| 32 | +#define COLS (getenv("COLS") ? atoi(getenv("COLS")) : 80) |
| 33 | +#define MAX(a, b) (a > b ? a : b) |
| 34 | +``` |
| 35 | + |
| 36 | +## Reusing generated bindings |
| 37 | + |
| 38 | +There is no way to reuse already generated bindings. |
| 39 | +Bindgen outputs bindings also for headers that were included in a given header. See @github[#2](#2). |
| 40 | + |
| 41 | +## Type qualifiers |
| 42 | + |
| 43 | +Type qualifiers `const`, `volatile` and `restrict` are not supported. |
| 44 | + |
| 45 | +## Updating extern variables |
| 46 | + |
| 47 | +Extern variables are read-only. See @github[scala-native/scala-native#202](scala-native/scala-native#202). |
0 commit comments