When you import types from C often you get name collision because of the reserved Nim keywords.
typedef struct
{
int type;
int another;
}AType;
Then when you want to import it to Nim
type
AType {.importc: "AType", header: "somewhere.h".} = object
type: cint
another: cint
...
var t: AType
t.type = 1
t.another = 2
Then the Nim complains about invalid use of the type keyword. Is there a way around this? Having "type" as a member in a C struct must be quite common.
Nim does allow importing fields with specific names. So you could rename the field typ or kind. As the following does.
type
AType {.importc: "AType", header: "somewhere.h".} = object
kind {.importc: "type".}: cint # could also name this `typ`
another: cint
...
var t: AType
t.kind = 1
t.another = 2