From 19c11bace91a02e1b1d97ab017955e0f04d79c36 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 31 Jul 2021 01:44:24 +0300 Subject: [PATCH] doc: document calling V from C --- doc/docs.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/docs.md b/doc/docs.md index b72f02334c..e4a60834ee 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -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 V has no special support for atomics, yet, nevertheless it's possible to treat variables as atomics