Thanks!

I could help you with c2nim – feel free to ping me on Discord if you like. I'd 
like to get the base idf layer automatically imported as well. Most of the 
current IDF wraps were done using c2nim.

You can look at how I use c2nim in 
[cimporter](https://github.com/elcritch/cimporter). I started making cimporter 
to essentially automate running c2nim on these sorts of projects, but never had 
time to document it. :)

Some useful c2nim settings to put into a base project settings using the C 
pragma syntax. Most of them could be set via CLI options too:
    
    
    #pragma c2nim strict
    #pragma c2nim importc
    #pragma c2nim cdecl
    #pragma c2nim header
    
    #pragma c2nim reordercomments // make C comments follow Nim style (mostly)
    #pragma c2nim mergeDuplicates // merge duplicates that arise after 
preprocessing
    #pragma c2nim skipFuncDefines // skip function bodies on inline c functions 
when using cdecl
    #pragma c2nim importFuncDefines
    
    #pragma c2nim mergeblocks // helps reduce number of times when certain C 
types can be defined out of order
    #pragma c2nim stdints // convert modern standard int's like uint8_t, etc
    #pragma c2nim cppSkipCallOp
    #pragma c2nim cppSkipConverter
    #pragma c2nim cppskipconverter
    
    #pragma c2nim render nonNep1Imports // useful to enable using nep1 with 
imports -- otherwise C file names won't match
    #pragma c2nim render extranewlines
    #pragma c2nim render reindentlongcomments
    
    
    Run

Here's some examples of name-mangling to fix certain imports:
    
    
    #pragma c2nim mangle "'va_list'" "varargs[pointer]" // convert va_list to 
nim's version
    #pragma c2nim mangle "'_Bool'" "bool" // how bools end up after 
preprocessing in clang -- should probably be handled in stdints above
    
    #pragma c2nim delete "RCUTILS_ERROR_STATE_FILE_MAX_LENGTH" // delete 
annoying C arrays or other bits
    #pragma c2nim delete "'rcutils/stdatomic_helper'" // remove broken c 
include -> nim import mappings -- unfortunately relies on the '/' in the name
    
    
    Run

Reply via email to