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.

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: 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

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: 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: 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: 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 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

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?

Re: mkdir; remove; under Windows throw Exception

2016-12-10 Thread unDEFER via Digitalmars-d-learn
On Saturday, 10 December 2016 at 18:30:53 UTC, Adam D. Ruppe wrote: On Saturday, 10 December 2016 at 18:09:43 UTC, unDEFER wrote: I know, but why it works in Linux by Linux documentation? Coincidence. That detail is undefined in the D documentation which means the implementation is free to

Re: mkdir; remove; under Windows throw Exception

2016-12-10 Thread unDEFER via Digitalmars-d-learn
On Saturday, 10 December 2016 at 14:10:15 UTC, ag0aep6g wrote: On 12/10/2016 04:39 AM, unDEFER wrote: man remove: remove - remove a file or directory That's documentation for C, not for D. I know, but why it works in Linux by Linux documentation?

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: 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: 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.

Delegates: Print 0..9

2016-12-01 Thread unDEFER via Digitalmars-d-learn
Hello! Simple using of delegates: === #!/usr/bin/rdmd import std.stdio; void main() { void delegate() functions[]; foreach (i; 0..10) { void print() { writefln("%s", i); } functions ~= } foreach (i; 0..10) {

Re: Delegates: Print 0..9

2016-12-01 Thread unDEFER via Digitalmars-d-learn
Yes, I have found: = #!/usr/bin/rdmd import std.stdio; void main() { void delegate() functions[]; foreach (i; 0..10) { auto get_print(int i) { void print() { writefln("%s", i); }

Re: Delegates: Print 0..9

2016-12-01 Thread unDEFER via Digitalmars-d-learn
On Thursday, 1 December 2016 at 20:12:15 UTC, Ali Çehreli wrote: First, the scary syntax that produces a lambda from an int: ... Better: ... All methods.. Thank you!

The order of libraries makes error in dub

2016-12-05 Thread unDEFER via Digitalmars-d-learn
Hello, dub makes string like the next to compile my program (WS_32.LIB at the beginning): $ dmd -m32mscoff -lib -of.dub\\build\\library-debug-windows-x86-dmd_2072-83D2723917096513EB360761C22DDD87\\db.lib -debug -g -w -version=Have_bdb2d WS_32.LIB libdb53d.lib source/berkeleydb/* -vcolumns

Re: How to use library compiled with Microsoft Visual Studio 2015 in D?

2016-12-05 Thread unDEFER via Digitalmars-d-learn
On Monday, 5 December 2016 at 07:21:30 UTC, Jacob Carlborg wrote: If you compile your D code with the "-m32mscoff" flag it will produce COFF objects and use the Visual Studio tool chain (linker and runtime). Compiling for 64bit (-m64) will always produce COFF objects. Big thanks! -m32mscoff

Re: How to use library compiled with Microsoft Visual Studio 2015 in D?

2016-12-05 Thread unDEFER via Digitalmars-d-learn
OK, I have found. It must be library WS2_32.LIB from Microsoft SDK. But dumpbin doesn't show __imp__htonl@4 symbol there. The magic! Thank you!

How to use library compiled with Microsoft Visual Studio 2015 in D?

2016-12-04 Thread unDEFER via Digitalmars-d-learn
Hello! I have compiled libdb (BerkeleyDB) with Microsoft Visual Studio 2015. 1) "Debug" mode. I have libdb53d.dll file. Do implib. The linker doesn't seen symbols from the library! Do "lib -l". In the list of symbols "db_create", linker searches "_db_create". Is it the problem? 2)

Re: The order of libraries makes error in dub

2016-12-05 Thread unDEFER via Digitalmars-d-learn
On Monday, 5 December 2016 at 11:51:52 UTC, unDEFER wrote: "libs-posix": ["db"], "sourceFiles-windows-dmd": ["libdb53d.lib", "WS_32.LIB"], "dflags-windows": ["-m32mscoff"], "subPackages": [ I understand that I don't must add "sourceFiles-windows-dmd" to lib project, I

Re: The order of libraries makes error in dub

2016-12-05 Thread unDEFER via Digitalmars-d-learn
On Monday, 5 December 2016 at 15:16:27 UTC, unDEFER wrote: 2) Its put to linker command at the first "libdb53d.lib WS2_32.lib" and AFTER that -m32mscoff. As result "cannot open file". Oh, the reason was mistype. And I have found how-to hide linker warning ("lflags-windows":

Re: The order of libraries makes error in dub

2016-12-05 Thread unDEFER via Digitalmars-d-learn
On Monday, 5 December 2016 at 14:59:26 UTC, Mike Parker wrote: "libs-windows-dmd":["libdb53d.lib","ws2_32.lib"] I have used "sourceFiles-windows-dmd", because it is the single that I could find. Thank you, "libs-windows-dmd":["libdb53d","WS2_32"] works much better, but again these errors:

Too slow readln

2017-07-16 Thread unDEFER via Digitalmars-d-learn
Hello, there! I have the next "grep" code: https://dpaste.dzfl.pl/7b7273f96ab2 And I have the directory to run it: $ time /home/undefer/MyFiles/Projects/TEST/D/grep "HELLO" . ./strace.log: [pid 18365] write(1, "HELLO\n", 6HELLO real1m17.096s user0m54.828s sys 0m13.340s The same

Re: Too slow readln

2017-07-16 Thread unDEFER via Digitalmars-d-learn
On Sunday, 16 July 2017 at 17:37:34 UTC, Jon Degenhardt wrote: On Sunday, 16 July 2017 at 17:03:27 UTC, unDEFER wrote: [snip] How to write in D grep not slower than GNU grep? GNU grep is pretty fast, it's tough to beat it reading one line at a time. That's because it can play a bit of a

Re: Too slow readln

2017-07-16 Thread unDEFER via Digitalmars-d-learn
I understand the main problem. dirEntries by default follows symlinks. Without it my first grep works only 28.338s. That really cool!

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
What the God? I was not ready to post... File file; try { file = File(path); } catch (Exception exp) { return; } try { //Some actions with file } catch (ErrnoException) { return; } catch (ErrnoException) is necessary

Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
Hello! I have the code like this: File file; try { file = File(path); } catch (Exception exp) { return; } ... try { }

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
On Thursday, 13 July 2017 at 08:53:24 UTC, Moritz Maxeiner wrote: Where does that `File` come from? If it's std.stdio.File, that one is a struct with internal reference counting, so it shouldn't crash in the above. Could you provide a minimal working (in this case crashing) example? Yes File

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
Thank you. I will write if will find the reason of description corruption.

Re: Bad file descriptor in File destructor

2017-07-13 Thread unDEFER via Digitalmars-d-learn
Seems I have found. I must do: try{ File file; try { file = File(path); } catch (Exception exp) { return; } //Some actions with file } catch (ErrnoException) { return; }

Re: How to make autocompletion for IDE?

2017-07-25 Thread unDEFER via Digitalmars-d-learn
On Tuesday, 25 July 2017 at 10:24:13 UTC, Andrea Fontana wrote: On Tuesday, 25 July 2017 at 10:23:33 UTC, Andrea Fontana wrote: On Tuesday, 25 July 2017 at 10:06:47 UTC, unDEFER wrote: Any ideas? I think you should use/contribute to DCD project https://github.com/dlang-community/DCC Andrea

Re: How to make autocompletion for IDE?

2017-07-25 Thread unDEFER via Digitalmars-d-learn
On Tuesday, 25 July 2017 at 10:35:14 UTC, Andrea Fontana wrote: If you want to add UFCS suggestions to DCD it would be useful for your project and all other IDEs too! Andrea Thank you, I will think. But if it was easy, authors self would do it :-)

How to make autocompletion for IDE?

2017-07-25 Thread unDEFER via Digitalmars-d-learn
Hello! I have written my text editor with highlighting, and now I want to add IDE features to it. I want to make autocompletion, but not only complete members of class/struct, but also all functions which maybe used with type, if the first argument of the function is this type. I.e. in

Re: How to make autocompletion for IDE?

2017-07-25 Thread unDEFER via Digitalmars-d-learn
On Tuesday, 25 July 2017 at 10:42:40 UTC, Basile B. wrote: I think that you underestimate the amount of work needed and your solution which is to use the compiler with -o- looks bad. What you really need is a compiler front-end which is basically what libdparse + DSymbol are. DCD uses them.

Re: Cast to subclass in the dmd compiler

2017-07-25 Thread unDEFER via Digitalmars-d-learn
I have found the answer in the code. Right code is: Import imp = m.isImport(); if (imp !is null) Thank you.

Cast to subclass in the dmd compiler

2017-07-25 Thread unDEFER via Digitalmars-d-learn
Hello! I'm hacking dmd compiler and trying to look on members array just after parse module. for(uint i = 0; i < members.dim; i++) { Dsymbol m = (*members)[i]; // It is good, but further: Import imp = cast(Import) m; if (imp !is null) { printf(" import %s.%s\n",

Hacking the compiler: Get Scope after some line of function

2017-07-27 Thread unDEFER via Digitalmars-d-learn
Hello! I'm trying to do some strange thing: compile some Statement (do semantic3 phase) in the scope of other function. Other function is for example: auto megafunction() { B b; uint a = 25; return b; } AST of this code looks like: FuncDeclaration { fbody = CompoundStatement

Re: Hacking the compiler: Get Scope after some line of function

2017-07-27 Thread unDEFER via Digitalmars-d-learn
On Thursday, 27 July 2017 at 11:59:51 UTC, unDEFER wrote: So how to get scope e.g. after line "B b;"? I have found. That in scopes was found symbols from declarations, you must iterate by declarations (DeclarationExp) and add symbols by sc.insert(decexp.declaration);

Re: Cast to subclass in the dmd compiler

2017-07-26 Thread unDEFER via Digitalmars-d-learn
On Wednesday, 26 July 2017 at 06:50:21 UTC, Jacob Carlborg wrote: For Expression, there's a field called "op" that indicates what kind of expression it is, which can used in combination with a cast. Thank you for hint!

Re: How to make autocompletion for IDE?

2017-07-26 Thread unDEFER via Digitalmars-d-learn
On Wednesday, 26 July 2017 at 07:41:20 UTC, Andrea Fontana wrote: Did you try with [1]? [1] http://forum.dlang.org/post/okktlu$2bin$1...@digitalmars.com Thank you, interesting. But I'm afraid it is not enough.

How to build dmd properly?

2018-12-18 Thread unDEFER via Digitalmars-d-learn
Hello, I have the next code (minimized with DustMite): struct Tup(T...) { bool opEquals() { foreach (i; T) static if (__traits(compiles, mixin("new InputRangeObject11261!(abs_class)"))) msg; } } /**/ void test3() {

Re: How to build dmd properly?

2018-12-18 Thread unDEFER via Digitalmars-d-learn
On Tuesday, 18 December 2018 at 15:54:28 UTC, Seb wrote: On Tuesday, 18 December 2018 at 14:35:46 UTC, unDEFER wrote: What I could build wrong and how to build dmd properly? Maybe you built dmd.d with debug assertions? (ENABLE_DEBUG=1) You can build dmd with the `./build.d` script or `make

Re: How to build dmd properly?

2018-12-18 Thread unDEFER via Digitalmars-d-learn
On Tuesday, 18 December 2018 at 16:19:33 UTC, unDEFER wrote: Yes, thank you for the hint. You are almost right. I did not ENABLE_DEBUG=1, but I also did not ENABLE_RELEASE=1 So it is the bug. I will report about it. https://issues.dlang.org/show_bug.cgi?id=19500

Re: Anonymous mapped regions increases unlimitely on spawn

2018-12-14 Thread unDEFER via Digitalmars-d-learn
So in digging by this problem, I have made simple patch to druntime. I have added in druntime/src/core/thread.d to final Thread start() nothrow of class Thread import core.stdc.stdio; printf("start Thread\n"); And to ~this() nothrow @nogc import core.stdc.stdio;

Re: Anonymous mapped regions increases unlimitely on spawn

2018-12-14 Thread unDEFER via Digitalmars-d-learn
So more digging.. dtor of Thread calls in GC.collect() if thread is finished. But it's do nothing because bool not_registered = !next && !prev && (sm_tbeg !is this); is always true... So how to register the thread?

Anonymous mapped regions increases unlimitely on spawn

2018-12-14 Thread unDEFER via Digitalmars-d-learn
Hello! I have the program which uses BDB and while testing often makes spawn. And after 12 hours of testing bdb said: mmap: Cannot allocate memory But the problem that I've found that it is not BDB created too many maps. Watching for /proc/[PID]/maps shows that number of anonymous mapped

Re: Anonymous mapped regions increases unlimitely on spawn

2018-12-14 Thread unDEFER via Digitalmars-d-learn
So it looks like a bug, and I have reported about it: https://issues.dlang.org/show_bug.cgi?id=19487

Re: How to debug FinalizeError?

2018-11-29 Thread unDEFER via Digitalmars-d-learn
On Thursday, 29 November 2018 at 14:51:40 UTC, Steven Schveighoffer wrote: You need to compile druntime in debug mode. One thing you can do is implement the function locally, and then break on it (it's a C linkage, so I think the linker will grab your copy instead of the one in druntime)

Re: How to debug FinalizeError?

2018-11-28 Thread unDEFER via Digitalmars-d-learn
No I'm not preallocating any exceptions. It was idea, but I removed all calls which can make throw. I'm using very old dmd 2.074.1, so as I have patched it for my text editor with IDE functions. I had a year break in development, so now I need to rewrite all my patches. But exactly the output

How to debug FinalizeError?

2018-11-28 Thread unDEFER via Digitalmars-d-learn
Hello! After long-long time of debugging, I just have decided InvalidMemoryOperationError in my program. But now my program after few hours of testing again crashes with "Finalization error". What this error means exactly? I again did something wrong in destructor? And how to debug it? I

Re: derelict-sdl2 automatically stripping the SDL_ prefix from names

2018-11-28 Thread unDEFER via Digitalmars-d-learn
Hello, as I know allMembers returns members not recursively. If you want to get really all members you need to make recursive function. In my program I used the next routine to print all members of module: static void allMembersOfModule(string module_name, bool root=false)() { static if

Re: Wich: opIndex overloading by return type

2020-04-19 Thread unDEFER via Digitalmars-d-learn
It is easy. You can make both types as children of common parent class myT, and when return myT.