Header pragma

The header pragma is very similar to the noDecl pragma: It can be applied to almost any symbol and specifies that it should not be declared and instead the generated code should contain an #include:

  1. type
  2. PFile {.importc: "FILE*", header: "<stdio.h>".} = distinct pointer
  3. # import C's FILE* type; Nim will treat it as a new pointer type

The header pragma always expects a string constant. The string constant contains the header file: As usual for C, a system header file is enclosed in angle brackets: <>. If no angle brackets are given, Nim encloses the header file in “” in the generated C code.

Note: This will not work for the LLVM backend.