Re: Returning cstring from a DLL

2018-12-13 Thread Stefan_Salewski
Your posted C code looks not too surprising for me, so I have no idea what the problem may be. Maybe you can try to investigate the cstring in more detail from inside your Delphi code, for example its address, content of each character, terminating NULL char. Maybe the problem is just the GC,

Re: bitsize in object? weird operation

2018-12-13 Thread MarcL
Thanks you, For some reason, it now works as expected, even without the packed pragma (which I will use anyway). The code produced is the correct one. The only difference on my systems (osx and linux) is that I changed from "brew install nim" or "apt install nim" to choosenim for both. Maybe..

Re: bitsize in object? weird operation

2018-12-13 Thread mashingan
I haven't used it but perhaps this help? [https://nim-lang.org/docs/manual.html#foreign-function-interface-packed-pragma](https://nim-lang.org/docs/manual.html#foreign-function-interface-packed-pragma)

Re: Change in nativesockets.nim

2018-12-13 Thread dom96
You just have to copy the constant values into Nim code. There is nothing better I'm afraid.

bitsize in object? weird operation

2018-12-13 Thread MarcL
Hi, I need to replicate the idea of C bitfields. struct iphdr { __u8ihl:4, version:4; } Run but in Nim, the closest I got is: IP_packet = object version{.bitsize:4.}:uint8

Re: startProcess alternative with lossless output stream

2018-12-13 Thread timothee
seems related to [https://github.com/nim-lang/Nim/issues/9953](https://github.com/nim-lang/Nim/issues/9953) /cc @araq @alaviss in your top-level example, when I use: let p = startProcess("{file_b2}", options = {{poParentStdin}}) (right now, pending my updating PR, I call it poParentStreams, ov

Re: Change in nativesockets.nim

2018-12-13 Thread MarcL
dom96, To achieve the real raw sockets, I need platform specific files. For example, I need some definitions which are inside /usr/include/in.h It leads to platform specific constants. (/usr/include/x86_64-linux-gnu/bits/). What is the best -nim- strategy to let nim automatically detect those i

Re: Unknown cause of AssertionError

2018-12-13 Thread mratsim
Unless you expect exact result because all you are doing is copying, as soon as computation is involved you need to check either the relative error or the absolute error or both. For instance, extracted [from my code](https://github.com/numforge/laser/blob/9fbb8d2a573d950573c7249e3a5d6cdd784a63

Re: Unknown cause of AssertionError

2018-12-13 Thread mashingan
as a rule-of-thumb, never use `==` equality to compare floating numeral

Re: Change in nativesockets.nim

2018-12-13 Thread MarcL
Will do. Where should I upload my proposals? Github? or here?

Re: Change in nativesockets.nim

2018-12-13 Thread dom96
Go for it. But note that nativesockets is meant to be low-level, don't put too much logic in there. The logic should go into `net` and `asyncnet`

Change in nativesockets.nim

2018-12-13 Thread MarcL
Hi, For "off the chart" networking programs, we need an empty service in Linux with SOCK_RAW, otherwise, it keeps bothering with /etc/services, which we don't want. so, in nativesockets.nim @@ -251,13 +251,14 @@ # FreeBSD, Haiku don't support AI_V4MAPPED but defines the mac

Re: Cannot prove initialization, again.

2018-12-13 Thread awr
I remember reading something a few years ago about the "this will eventually be a compile-time error" thing being an inaccurate statement. If something like that were added in the future, given Nim's direction, I would wager you could probably get around it with a future compiler pragma.

Re: Calling stdcall from .dll

2018-12-13 Thread awr
AFAIK the `--noMain` doesn't mean "don't generate `NimMain()`". You still need to `NimMain()` to boot the GC, execute top-level module code, etc. I believe what the flag actually does is prevent `NimMain()` being called in `DllMain()`, so you have to call `NimMain()` manually.

Re: Cannot prove initialization, again.

2018-12-13 Thread lscrd
It seems that I was not in a great shape yesterday. There are some errors in my message. Indeed, a set of _range[ '0'..'9']_ will occupy 58 bits rounded to 64, not 9 bits rounded to 16. I will have to declare _Digit_ as a _range[0..9]_ to use only 10 bits (not 9!) rounded to 16 and, in this cas