Re: Is it possible to import C #define constants without knowing their values?

2016-07-31 Thread endragor
This is a similar issue: [https://github.com/nim-lang/Nim/issues/4441](https://github.com/nim-lang/Nim/issues/4441) There is a workaround offered in comments that is to import the constant as a procedure instead of a variable: proc foo(): cint {.importcpp: "FOO@".}

Is it possible to import C #define constants without knowing their values?

2016-07-31 Thread cjxgm
Well, importing itself can be done easily like this: {.emit: """ #define HELLO_WORLD 10 """.} var x {.importc: "HELLO_WORLD", nodecl.}: cint echo x This will generate `LOC1 = nimIntToStr(((NI) (HELLO_WORLD)));`, which directly uses the name. Good. But