Re: Strings and C.

2018-02-18 Thread DTxplorer
That makes sense.

Re: Strings and C.

2018-02-18 Thread Stefan_Salewski
It is generally a bad idea to send the whole seq to C function because there may reside additional data like seq length at start of memory chunk. Try to use address of first element of the sequence instead.

Re: Strings and C.

2018-02-18 Thread DTxplorer
Thanks again cdome. I have another question with C but I want to avoid polluting the homepage with noobish topics. And strings are kind of sequence isn't it ? I want to pass a sequence to a C function but the result is unexpected. Two files for minimal example. proc print_array(t

Re: Strings and C.

2018-02-15 Thread cdome
Correct: proc print_string*(input_string: cstring, size: cint) {.header: "cfunction.h", importc:"print_string".}

Strings and C.

2018-02-15 Thread DTxplorer
Hi I imported a c function who take a char array as argument. I pass a Nim string to it but the 3 first characters aren't expected, like this one "|" and random special chars who can't be displayed by the forum. Code example import streams #import the c function. proc