How can I pass shared memory between threads?

2020-05-20 Thread Keithcat1
Hi, Does Nim have some good ways to handle shared memory? The only way I found was manual memory management, but that can't handle inner references and, hello, that's the reason I'm using a garbage collected language in the first place :D The experimental manual says that the parallel statement

Does Nim have a binary serializer similar to Gos "encoding/gob"?

2020-04-17 Thread Keithcat1
Hi, I'm looking for a binary serializer that will hopefully allow newer versions of my program that for example add new fields to a type to still load data created by older versions of that same program. Is there anything like that? Thanks!

Could Nim use Cmake to invoke the C compiler?

2020-04-17 Thread Keithcat1
I'm curious, would it be hard or beneficial to change the nim compiler so that every time you build a project, it generates a cmake_lists.txt file and uses Cmake to run the C or C++ compiler to compile the project. This seems to be at least one of the things that Cmake was made for. You might al

Calling C function causes Sigsegv

2020-04-07 Thread Keithcat1
Hi, I'm trying to wrap a function of BASS sound library so I can learn how it works. My code is: #{. emit: """#include "bass.h" """ .} type dword {. importc: "DWORD" .} = uint32 type hwnd {. importc: "HWND" .} = uint32 type guid {. importc: "struct GUID" .}= object ty

Re: How do I pass Nim functions to C code as callbacks?

2020-04-07 Thread Keithcat1
OK, here is an example. logic.c: typedef int (adder)(int, int); int run(adder fn, int a, int b) { return fn(a, b); } logic.nim: {. compile: "logic.c" .} type adder {. importc .} = proc(a, b: cint): cint proc run(fn: adder, a, b: cint): cint {. importc, cdecl, nodecl .} proc add(a, b: cint)

How do I pass Nim functions to C code as callbacks?

2020-04-07 Thread Keithcat1
H. I've looked around and I can't answer this. I want to be able to pass a Nim function / proc to C as a function pointer and get C to call it. I don't have a specific reason I want to do this, but I might need it soon. Thanks