exportc -

2021-02-06 Thread shirleyquirk
yes, sorry, meant that that snippet reproduces the bug

How to port this c-enum to nim?

2021-02-06 Thread shirleyquirk
how about separating them into groups, this also makes sense, as OP_ALU/OP_STACKGROUP1 are not opcodes, they're just constants or categories. maybe: const #or enum if you switch on their values somewhere OpAlu = 0x80 OpStackGroup1 = 0x90 OpStac

exportc -

2021-02-06 Thread mantielero
Well I fixed the issues by replacing `cint` with `int32`, `cdouble` with `float64` and `cuint` with `uint32`. Thanks a lot for your help.

exportc -

2021-02-06 Thread shirleyquirk
I also wanted to suggest that you use `import` instead of `include`, it avoids type redefinitions, promotes information hiding and modularity, and makes you more attractive.

How to port this c-enum to nim?

2021-02-06 Thread SolitudeSF
nim enums cant have duplicate values

exportc -

2021-02-06 Thread shirleyquirk
Lesson/workaround: Don't `{.exportc.}` ctypes. your options: ##fmi2TypesPlatform.nim type #fmi2Boolean*{.exportc:"$1".} = cint #no fmi2Boolean* = cint #fine results in "int" fmi2Boolean* = int32 #fine results in "NI32" fmi2Boolean*{.exportc:"$1".} =

exportc -

2021-02-06 Thread mantielero
I am getting this: $ nim c --nimcache:.cache --app:lib -o:inc.so bar.nim Hint: used config file '/home/jose/.choosenim/toolchains/nim-1.4.2/config/nim.cfg' [Conf] Hint: used config file '/home/jose/.choosenim/toolchains/nim-1.4.2/config/config.nims' [Conf] .CC: stdl

exportc -

2021-02-06 Thread shirleyquirk
Here's a minimal working example: ##foo.nim type Foo*{.exportc.} = cint Run ##bar.nim import foo proc bar*(f: var Foo){.exportc.} = #anything here, just so bar gets emitted f = 3 Run related to

exportc -

2021-02-06 Thread mantielero
Maybe related to [this](https://github.com/nim-lang/Nim/issues/7448).

How to port this c-enum to nim?

2021-02-06 Thread dirkmo
As my first Nim project, I want to port a hobby project of mine (written in C) to Nim. In my C project, I have defined a huge enum: typedef enum { OP_ALU = 0x80, OP_ADD = OP_ALU | 0x0, OP_SUB = OP_ALU | 0x1, OP_AND = OP_ALU | 0x2,

Is using gcsafe with --gc:arc correct here with producer/consumer?

2021-02-06 Thread treeform
Thank you! Is true if instead of passing integers I pass ref objects? This appears to work: # Producer consumer with regular nim threads: import locks, os var qLock: Lock consumers: array[0 .. 9, Thread[void]] type RefObject = ref object name:

exportc -

2021-02-06 Thread mantielero
My bad. Is it fine now?

exportc -

2021-02-06 Thread shirleyquirk
Not visible, is it maybe private?

exportc -

2021-02-06 Thread mantielero
The code goes as follows: [inc.nim](https://github.com/mantielero/fmi.nim/blob/main/src/inc.nim)

exportc -

2021-02-06 Thread shirleyquirk
I think we need more information about what else is going on in inc.nim. codegen errors are not your fault, but it would help to have a minimal reproducible example

exportc -

2021-02-06 Thread mantielero
I am tryin to port some C code to Nim, but I need to meet a particular API. To do so I am using `externc`. But when I compile the code it looks like it is not finding what I am looking for. I have something like this: type fmi2Boolean* {.exportc:"$1".} = cint R

generic functions : syntax / deduction / debugging

2021-02-06 Thread HJarausch
Many thanks to both of you. I am approaching the **Art of Nim Programming**

Exploring namespaces support in Nim

2021-02-06 Thread cblake
If you want to allow multiple `moduleA as a, moduleB as b, ..` then I think you need a tiny macro, for example: import macros macro imp*(imports: varargs[untyped]): untyped = result = newStmtList() for i in imports: result.add quote do: from `i` import nil

generic functions : syntax / deduction / debugging

2021-02-06 Thread doofenstein
the issue is that static[Natural] already is a value not the type of the value: func `*`[ArrSize: static[Natural], T:typedesc]( elems: array[ArrSize, T], times: static[Cnt]): array[Cnt * ArrSize, T] = Run Though there's another issue. Writing typedesc is not the

generic functions : syntax / deduction / debugging

2021-02-06 Thread Krux02
so funktioniert es func `*`[ArrSize: static[Natural], T](elems: array[ArrSize, T], times: static[Natural]): array[times * ArrSize, T] = for idx in 0 ..< times: for arrIdx, item in pairs(elems): result[idx * ArrSize + arrIdx] = item const test = ["

generic functions : syntax / deduction / debugging

2021-02-06 Thread HJarausch
I am searching for documentation about generic functions in Nim * what is the syntax for generic parameters in brackets * how does the deduction of generic parameters work - what are its limitations * how to debug E.g., the error message in the following example puzzles me. Here I try to

asynchttpserver, keep-alive and concurrent queries

2021-02-06 Thread benob
Thank you for help, and sorry to bother you with my bugs.