Re: Separate IP parts

2016-12-09 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 10 December 2016 at 03:51:34 UTC, brocolis wrote: How do I separate IP parts with dlang? I found this very cool trick, with C++: http://stackoverflow.com/a/5328190 std::string ip ="192.168.1.54"; std::stringstream s(ip); int a,b,c,d; //to store the 4 ints char ch; //to

Separate IP parts

2016-12-09 Thread brocolis via Digitalmars-d-learn
How do I separate IP parts with dlang? I found this very cool trick, with C++: http://stackoverflow.com/a/5328190 std::string ip ="192.168.1.54"; std::stringstream s(ip); int a,b,c,d; //to store the 4 ints char ch; //to temporarily store the '.' s >> a >> ch >> b >> ch >> c >> ch >> d;

Re: mkdir; remove; under Windows throw Exception

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Saturday, 10 December 2016 at 03:36:11 UTC, Adam D. Ruppe wrote: On Saturday, 10 December 2016 at 03:29:18 UTC, unDEFER wrote: But it works under Linux That's just because the underlying C function handles the case. But the D function makes no promises about that: std.file.remove's

Re: mkdir; remove; under Windows throw Exception

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Saturday, 10 December 2016 at 01:30:52 UTC, Jonathan M Davis wrote: On Saturday, December 10, 2016 01:19:45 unDEFER via Digitalmars-d-learn wrote: Well, much as I'd love to rag on Windows for doing dumb and annoying stuff with file locks (which they do do), in this case, your code

Re: mkdir; remove; under Windows throw Exception

2016-12-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 10 December 2016 at 03:29:18 UTC, unDEFER wrote: But it works under Linux That's just because the underlying C function handles the case. But the D function makes no promises about that: std.file.remove's documentation says "removes the file", leaving what it does to

Re: mkdir; remove; under Windows throw Exception

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Saturday, 10 December 2016 at 01:28:13 UTC, SonicFreak94 wrote: On Saturday, 10 December 2016 at 01:19:45 UTC, unDEFER wrote: remove("D:\\TEST"); Try rmdir instead. But it works under Linux

Re: The module 'foo' is already defined in 'libmylib.so'

2016-12-09 Thread timotheecour via Digitalmars-d-learn
On Saturday, 10 December 2016 at 02:39:33 UTC, timotheecour wrote: Have a look at what `trace -E d_executable args` and `trace -E c++_executable args` print on startup and grep for dlopen calls and the like. do you mean strace? I have trace on OSX but I'm asking for linux. Looking at the

Re: The module 'foo' is already defined in 'libmylib.so'

2016-12-09 Thread timotheecour via Digitalmars-d-learn
Have a look at what `trace -E d_executable args` and `trace -E c++_executable args` print on startup and grep for dlopen calls and the like. do you mean strace? I have trace on OSX but I'm asking for linux.

Re: staticIota is easy

2016-12-09 Thread Ali Çehreli via Digitalmars-d-learn
On 12/09/2016 05:34 PM, Stefan Koch wrote: On Friday, 9 December 2016 at 18:52:59 UTC, Ali Çehreli wrote: I thought I needed something like staticIota in a unittest to effect static foreach over a number range and I found one in druntime's implementation:

Re: staticIota is easy

2016-12-09 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 9 December 2016 at 18:52:59 UTC, Ali Çehreli wrote: I thought I needed something like staticIota in a unittest to effect static foreach over a number range and I found one in druntime's implementation: https://github.com/dlang/druntime/blob/master/src/core/internal/traits.d#L106

Re: mkdir; remove; under Windows throw Exception

2016-12-09 Thread SonicFreak94 via Digitalmars-d-learn
On Saturday, 10 December 2016 at 01:19:45 UTC, unDEFER wrote: remove("D:\\TEST"); Try rmdir instead.

Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Friday, 9 December 2016 at 21:20:12 UTC, Martin Krejcirik wrote: On Friday, 9 December 2016 at 16:50:05 UTC, unDEFER wrote: And in mini program it works and shows diagnostic message. Where my diagnostic message in more complicate program??? Try redirecting stdout and stderr to a file(s).

Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Friday, 9 December 2016 at 20:35:07 UTC, Ali Çehreli wrote: Assuming boundschecking is turned off, I think you get unlucky in the mini program and happen to hit a '\0' byte. No, no.. the program built in debug mode with dub.

mkdir; remove; under Windows throw Exception

2016-12-09 Thread unDEFER via Digitalmars-d-learn
Hello! $ cat try.d import std.file; void main () { mkdir("D:\\TEST"); remove("D:\\TEST"); } $ ./try.exe std.file.FileException@std\file.d(731): D:\TEST: Access Denied. What I don't know about removing directories in Windows? Why I can't remove directory

Re: The program exits unexpectedly

2016-12-09 Thread Martin Krejcirik via Digitalmars-d-learn
On Friday, 9 December 2016 at 16:50:05 UTC, unDEFER wrote: And in mini program it works and shows diagnostic message. Where my diagnostic message in more complicate program??? Try redirecting stdout and stderr to a file(s). There are cases when the console itself can crash.

Re: The program exits unexpectedly

2016-12-09 Thread Ali Çehreli via Digitalmars-d-learn
On 12/09/2016 08:50 AM, unDEFER wrote: > On Friday, 9 December 2016 at 14:29:38 UTC, unDEFER wrote: >> I'm afraid that the problem that my program wants to say something, >> but there is no "flush" so message leaves in the buffer. > > I have found, it was code like: > > string path = "C:"; >

staticIota is easy

2016-12-09 Thread Ali Çehreli via Digitalmars-d-learn
I thought I needed something like staticIota in a unittest to effect static foreach over a number range and I found one in druntime's implementation: https://github.com/dlang/druntime/blob/master/src/core/internal/traits.d#L106 (I wonder why that one is implemented in divide-and-conquer

Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Friday, 9 December 2016 at 14:29:38 UTC, unDEFER wrote: I'm afraid that the problem that my program wants to say something, but there is no "flush" so message leaves in the buffer. I have found, it was code like: string path = "C:"; string parent = path[0..path.lastIndexOf("\\")]; And in

Re: Range of uncopyable elements

2016-12-09 Thread Jerry via Digitalmars-d-learn
On Thursday, 8 December 2016 at 23:08:35 UTC, Jonathan M Davis wrote: I've seen that in C++ code all the time, especially if you're dealing with smart pointers, because otherwise you have to do stuff like (*iter)->foo() instead of just var->foo(). Smart pointers weren't introduced until

Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
I'm afraid that the problem that my program wants to say something, but there is no "flush" so message leaves in the buffer.

Re: @property

2016-12-09 Thread ArturG via Digitalmars-d-learn
My issue isn't about @property, it just shows 3 cases where i think that dmd is missing a check for alias this. Even if D didnt had @property or parentesis less function call, due to alias opCall this it should be possible to call opCall without parentesis.

Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Friday, 9 December 2016 at 10:08:24 UTC, unDEFER wrote: On Friday, 9 December 2016 at 09:42:52 UTC, unDEFER wrote: Exceptions works good, and prints debug message always. It is not exception.. I have tried to add try/catch around full loop of the program. It doesn't work. And program has

Re: @property

2016-12-09 Thread Satoshi via Digitalmars-d-learn
On Thursday, 8 December 2016 at 22:09:14 UTC, Jonathan M Davis wrote: On Thursday, December 08, 2016 16:54:57 Adam D. Ruppe via Digitalmars-d- learn wrote: [...] Yeah, it's pretty common for folks to slap @property on functions to make it clear that it's intended to be used as a property

Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Friday, 9 December 2016 at 09:42:52 UTC, unDEFER wrote: Exceptions works good, and prints debug message always. It is not exception.. I have tried to add try/catch around full loop of the program. It doesn't work. And program has infinite loop. But maybe it is unhandled signal? I have

Re: The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
On Friday, 9 December 2016 at 09:29:36 UTC, rikki cattermole wrote: On 09/12/2016 10:26 PM, unDEFER wrote: An exception/error might be thrown, try catching Error's in the threads function. Also try adding an infinite loop to it. Exceptions works good, and prints debug message always. It is

Re: The program exits unexpectedly

2016-12-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/12/2016 10:26 PM, unDEFER wrote: Hello! I'm starting port my program to Windows _without_ Cygwin and found big trouble. My main thread exits unexpectedly without any diagnostic messages. The second thread still lives when it happens. The visual studio debugger say that thread exits with

The program exits unexpectedly

2016-12-09 Thread unDEFER via Digitalmars-d-learn
Hello! I'm starting port my program to Windows _without_ Cygwin and found big trouble. My main thread exits unexpectedly without any diagnostic messages. The second thread still lives when it happens. The visual studio debugger say that thread exits with code 2. What it maybe?