Hmmm, that could be useful for those large C wrapper projects.

One approach might be to provide a test function that just takes the address to 
each proc so the compiler thinks it's used. Like this (untested) code:
    
    
    proc someFFI*() {.importc: "$1"}
    
    proc useSomeFFI*() =
      someFFI()
    
    proc testFFIs*(fns: varargs[typed, unsafeAddr]) =
      for fnptr in fns:
        discard # not sure if Nim will be smart enough to elide this, but you 
could do a null op, etc
    
    when isMainModule:
      testFFIs(useSomeFFI)
    
    
    Run

You could create a pragma of `{.includeBuild.}` to do by adding to a compile 
time list and doing similar.

I'd be up for adding such a pragma macro to 
[cdecl](https://github.com/elcritch/cdecl) as a useful edge for testing C FFI 
as I have projects I could use it on. Presuming there's no cleaner approach.

Reply via email to