With `c2nim`, my experience goes as follows. You normally run it like this: 
    
    
    c2nim --header capi.h
    
    
    Run

It worked! Well, not really. For this header you get everything commented. You 
need to know where it fails. To know that, you should use `--strict`: 
    
    
    $ c2nim --header --strict capi.h
    capi.h(150, 22) Error: token expected: ; but got: *
    
    
    Run

The parser is not helping much here. The problem is that it found something it 
was not expecting. In this case: `TESS_API`. Normally it would be replaced by 
something else. If you simply remove it in all the file, you will see it 
creates the bindings for you.

It is annoying having to modify the header manually. You can avoid that by 
creating a file **tesseract.c2nim** : 
    
    
    #ifdef C2NIM
    #def TESS_API
    #endif
    
    
    Run

(explained 
[here](https://github.com/nim-lang/c2nim/blob/master/doc/c2nim.rst#def-directive))

Then you simply, execute: 
    
    
    c2nim --header --strict tesseract.c2nim capi.h
    
    
    Run

> with the capi.h unmodified

and you get your bindings.

I hope this helps.

Reply via email to