You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have installed `cjbind` according to the instructions in [Installation](/en/guide/install) and can view the version number using the `cjbind --version` command, you can use the `cjbind` command to generate FFI binding code.
4
+
5
+
The `cjbind` command takes a C header file path as input and optionally specifies an output file path for the generated bindings. If no output file path is provided, the binding code will be output to `stdout`.
6
+
7
+
If we want to generate Cangjie FFI bindings from a C header file named `library.h` and place them in a `cjbind_ffi.cj` file, we can invoke `cjbind` like this:
8
+
9
+
```bash
10
+
$ cjbind -o cjbind_ffi.cj library.h
11
+
```
12
+
13
+
To view more detailed help information, pass the `--help` argument:
14
+
15
+
```text
16
+
$ cjbind --help
17
+
Automatically generate FFI bindings from C libraries to Cangjie.
18
+
19
+
Usage: cjbind <OPTIONS> <HEADER> -- <CLANG_ARGS>
20
+
21
+
Arguments:
22
+
<HEADER> C header file path
23
+
[CLANG_ARGS]... Arguments that will be passed directly to clang
24
+
25
+
Options:
26
+
--no-enum-prefix When generating enums, do not use enum names as prefixes for enum values
27
+
--no-detect-include-path Disable automatic include path detection
28
+
--no-comment Do not attempt to generate comments in the code
29
+
--no-layout-test Do not generate layout test code
30
+
--builtins Generate bindings for builtin definitions like __builtin_va_list
31
+
--make-func-wrapper Generate foreign function wrappers to allow calls from outside the package
32
+
--func-wrapper-suffix <SUFFIX> Suffix used when generating function wrappers, defaults to _cjbindwrapper
33
+
--auto-cstring Convert char* to CString instead of CPointer<UInt8>
34
+
--array-pointers-in-args Convert arrays T arr[size] to VArray<T, $size> instead of CPointer<T>
35
+
--make-cjstring Convert C strings to Cangjie String instead of VArray<UInt8>, which may cause binary representation inconsistency
36
+
-o, --output <FILE> Output the generated bindings to a file
37
+
-p, --package <PACKAGE> Package name in the generated bindings
0 commit comments