Hi,
if I want to use the importc pragma, but the header containing the function I want only works properly, if prefixed by one or more other headers, how do I do this?
This is the example in the doc:
proc printf(formatstr: cstring) {.header: "<stdio.h>", importc: "printf", varargs.}
Run So, what if "<abc.h>" needed to be imported before "<stdio.h>"?header pragma allows multiple headers in the following way:
proc myProc() {.importc, header: """#include <abc.h>
#include <stdio.h>""".}
It is worth noting that header pragma better be avoided as it makes your file dependent on the header. When function or struct ABI is well defined, you can easily get away with just importc pragma.