1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

doc: document calling V from C

This commit is contained in:
Alexander Medvednikov 2021-07-31 01:44:24 +03:00 committed by GitHub
parent 0675079b98
commit 19c11bace9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4268,6 +4268,23 @@ fn main() {
} }
``` ```
## Calling V from C
Since V can compile to C, calling V code from C is very easy.
By default all V functions have the following naming scheme in C: `[module name]__[fn_name]`.
For example, `fn foo() {}` in module `bar` will result in `foo__bar()`.
To use a custom export name, use the `[export]` attribute:
```
[export: 'my_custom_c_name']
fn foo() {
}
```
## Atomics ## Atomics
V has no special support for atomics, yet, nevertheless it's possible to treat variables as atomics V has no special support for atomics, yet, nevertheless it's possible to treat variables as atomics