diff options
Diffstat (limited to 'doc/backends.md')
-rw-r--r-- | doc/backends.md | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/doc/backends.md b/doc/backends.md index 5258e9b4d..9f0c54835 100644 --- a/doc/backends.md +++ b/doc/backends.md @@ -250,6 +250,8 @@ which will likely make your program crash at runtime. The name `NimMain` can be influenced via the `--nimMainPrefix:prefix` switch. Use `--nimMainPrefix:MyLib` and the function to call is named `MyLibNimMain`. +When compiling to static or dynamic libraries, they don't call destructors of global variables as normal Nim programs would do. A C API `NimDestroyGlobals` is provided to call these global destructors. + ### Nim invocation example from C @@ -300,7 +302,7 @@ Instead of depending on the generation of the individual ``.c`` files you can also ask the Nim compiler to generate a statically linked library: ```cmd - nim c --app:staticLib --noMain fib.nim + nim c --app:staticLib fib.nim gcc -o m -Inimcache -Ipath/to/nim/lib maths.c libfib.nim.a ``` @@ -371,11 +373,7 @@ The manual mentions that [Nim strings are implicitly convertible to cstrings](manual.html#types-cstring-type) which makes interaction usually painless. Most C functions accepting a Nim string converted to a `cstring` will likely not need to keep this string around and by the time -they return the string won't be needed anymore. However, for the rare cases -where a Nim string has to be preserved and made available to the C backend -as a `cstring`, you will need to manually prevent the string data -from being freed with [GC_ref](system.html#GC_ref,string) and [GC_unref]( -system.html#GC_unref,string). +they return the string won't be needed anymore. A similar thing happens with C code invoking Nim code which returns a `cstring`. Consider the following proc: |