I wrote a library which is intended to be used in C as well.
Compiling the library to a .dll
/.so
/.lib
itself is well documented and works as expected.
However, I cannot find anything regarding the corresponding header files.
The only documentation for something like this that I found, is the --header
cli argument which was supposedly (to be?) removed.
Can't find it in the https://nim-lang.org/docs/nimc.html page, nor in the help-page of my installation.
Nim-Version:
$ nim -v
Nim Compiler Version 1.6.0 [Windows: amd64]
Compiled at 2021-10-19
In the documentation for the exportc
pragma, it only explains the naming and how it can be used.
Same goes for the backend-integration Page, which also doesn't state anything helpful regarding header files.
Is there a proper way to generate the header-files from nim-source code, or do I have to write these manually?
You can use the Genny nimble package to generate a C header file (and also Python and Node.js bindings!) for your Nim library.
Besides that, writing the header manually would be the next best choice. Well, the --header
option does still happen to work, but it's not recommended to use it as it's undocumented and unsupported.