ok fixed i had to call NimMain(); this fixed everything
PyMODINIT_FUNC
PyInit_fib(void)
{
NimMain();
return PyModule_Create(_module);
}
thx this got the $fpx working now getting a segfault when i do open(), ill
investigate further i guess its something related it works perfectly fine when
not calling it from c.
Ok, so the problem is likely that Nim runtime is not initialized. Try
setupForeignThreadGc() at the beginning of your proc. TBH, i don't remember
exactly how this is done...
yes i tried that but if i do $fpx i get a segfault on the $fpx valgrind segfult
line the compiled code is at fp = cstrToNimstr(fpx);
What's your C code then? Are you calling this proc from C program or from Nim
program? If C program, Nim's GC might not be initialized.
if it helps this is the valgrind output
==9355== Process terminating with default action of signal 11 (SIGSEGV)
==9355== Access not within mapped region at address 0x0
==9355==at 0x665CA1B: lowGauge_3mwQtFaBTgevFrybZdgUNw
(stdlib_system.c:1380)
==9355==by
Yup, that works.
For anyone looking to spot the difference, here is original signature:
template defineIndex*(name, source: typedesc, extractIt, cmpAB: untyped)
{.immediate.} = ...
When you just remove the immediate, it breaks. Here is the working signature:
First way is correct, except conversion from cstring to string should be made
with $.
proc read_csv(fpx: cstring): void {.exportc.} =
let fp = $fpx
var s = newFileStream(fp, fmRead)
if s == nil:
echo "file not found"
return
How can you pass a char * to nim, ive been trying for a while but i keep
getting segfault.
if i use:
proc read_csv(fpx: cstring): void {.exportc.} =
let fp: string = cast[string](fpx)
var s = newFileStream(fp, fmRead)
if s == nil:
echo "file not
Try this prototype:
template defineIndex*(name, source, extractIt, cmpAB: untyped) = ...
I have now written a [blog post about
this](http://www.bootstrap.me.uk/bootstrapped-blog/nim-for-the-discerning-rubyist)
Feel free to ignore the first, introductory, part
Hey folks!
As the immediate pragma is deprecated, I'm updating my packages to remove
references to it. I've got one situation where I'm curious about the best
alternative. It's [this
template](https://github.com/Nycto/RBTreeNim/blob/a64b6a8ad230a8a8f34e7ce1f6564ebf423a5b17/rbtree.nim#L34-L72).
The only static parts of the Tensor types are the Backend (Cpu, CUDA, ...) and
the internal type (int32, float32, object ...).
The network topology will be dynamic and using dynamic graphs more akin to
PyTorch/Chainer/DyNet than Theano/Tensorflow/Keras.
My next step is to build an autograd so
Thank you all !
@Stevo, can you pls provide some examples of how to use it ?
For anyone facing a similar problem, I centralized my build configuration here:
[https://github.com/Nycto/ExtraNimble](https://github.com/Nycto/ExtraNimble)
It does (basically) everything I asked for in this thread above, though I had
to do a few hacky things to get it working.
15 matches
Mail list logo