genotrance / nimgen

Nimgen is a helper for c2nim to simplify and automate the wrapping of C libraries
MIT License
114 stars 11 forks source link

how to use with header-only #40

Closed brentp closed 5 years ago

brentp commented 5 years ago

I am trying to use a header-only library (https://github.com/Genomicsplc/variantkey/blob/master/c/src/variantkey/variantkey.h) . I have this cfg:

[n.global]
output = src

[n.include]
src/include

[hex.h]
preprocess = true

[variantkey.h]
preprocess = true
defines = true
rename = "variantkey_sys.nim"

[variantkey_sys.nim]
prepend = """
type
  uint8_t* = uint8
  int8_t* = int8
  uint16_t* = uint16
  uint32_t* = uint32
  uint64_t* = uint64
  size_t* = csize
"""

it seems that nimgen is going in and commenting out the actual implementation in the header files. Is there a way to use this with header-only stuff? thanks.

genotrance commented 5 years ago

I think @jyapayne dealt with static inline recently in his [libnx] (https://github.com/jyapayne/nim-libnx) wrapper.

I've also find a header only wrapper in nimfuzzy if that helps too.

brentp commented 5 years ago

hi, thanks for the response. I had a look at those, but don't see what to change. I put what I have here: https://github.com/brentp/variantkey-nim any ideas?

brentp commented 5 years ago

I only need 3 functions in this entire library so I just moved the .h to .c, exported the functions needed to a new .h and used c2nim. I htink this is the simplest solution for now (and the only one I could get to work).