Ivan FB 85931bad92
fix(macro): avoid caller-thread GC alloc in ffiNewReq
ffiNewReq derived the request id with `let typeStr = $T`, allocating a
Nim GC string on the *calling* thread for every request. Embedded in a
foreign host (e.g. Go) the callers are transient, concurrent OS threads;
running Nim's GC there corrupts the heap under load. The type name is
known at compile time, so emit it as a `cstring` literal (the same value
already used as the registry key) — no runtime allocation. Applies to
both the {.ffi.} and {.ffiCtor.} request builders.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 20:09:40 +02:00
2026-05-11 19:21:40 -03:00
2026-06-18 11:47:22 +02:00

nim-ffi

Allows exposing Nim projects to other languages

Example

examples/nim_timer is now a self-contained Nimble project that imports nim-ffi directly. Use cd examples/nim_timer && nimble install -y ../.. && nimble build to compile the example.

Description
Allows exposing Nim projects to other languages
Readme
Languages
Nim 84.4%
Smarty 7.3%
C++ 3.4%
CMake 2.7%
C 2.2%