Re: Wich: opIndex overloading by return type
It is easy. You can make both types as children of common parent class myT, and when return myT.
Re: How to build dmd properly?
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: How to build dmd properly?
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 -f posix.mak -j4` (assuming you are in `src). Anyway, the internal assertions should never fail, so this definitely deserves a bug report if that was the case. 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.
How to build dmd properly?
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() { Tup!(int, double) ; } interface InputRange11261(E) { } template InputRangeObject11261(R) { alias typeof(init.front()) E; class InputRangeObject11261 : InputRange11261!E { } } class abs_class { } The problem that I'm compiling dmd v2.083.1 and the version which built I gives me the next error: --- ERROR: This is a compiler bug. Please report it via https://issues.dlang.org/enter_bug.cgi with, preferably, a reduced, reproducible example and the information below. DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction. --- DMD v2.083.1 predefs DigitalMars Posix linux ELFv1 CRuntime_Glibc CppRuntime_Gcc LittleEndian D_Version2 all D_SIMD D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat binarydmd version v2.083.1 config /mnt/raid/system/home/undefer/MyFiles/Sources/D/dmd/generated/linux/release/64/dmd.conf DFLAGS -I/mnt/raid/system/home/undefer/MyFiles/Sources/D/dmd/generated/linux/release/64/../../../../../druntime/import -I/mnt/raid/system/home/undefer/MyFiles/Sources/D/dmd/generated/linux/release/64/../../../../../phobos -L-L/mnt/raid/system/home/undefer/MyFiles/Sources/D/dmd/generated/linux/release/64/../../../../../phobos/generated/linux/release/64 -L--export-dynamic -fPIC --- core.exception.AssertError@dmd/dsymbolsem.d(5356): Assertion failure ??:? _d_assertp [0xf0233ed] dmd/dsymbolsem.d:5356 _ZN22DsymbolSemanticVisitor5visitEP20InterfaceDeclaration [0xee4c9a0] dmd/dclass.d:1129 _ZN20InterfaceDeclaration6acceptEP7Visitor [0xee0a439] dmd/dsymbolsem.d:378 _Z15dsymbolSemanticP7DsymbolP5Scope [0xee3d538] dmd/dtemplate.d:7427 void dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*) [0xee5ff53] dmd/dtemplate.d:7445 void dmd.dtemplate.TemplateInstance.tryExpandMembers(dmd.dscope.Scope*) [0xee5ffca] dmd/dsymbolsem.d:5671 void dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) [0xee4d3ce] dmd/dsymbolsem.d:2573 _ZN22DsymbolSemanticVisitor5visitEP16TemplateInstance [0xee443be] dmd/dtemplate.d:7474 _ZN16TemplateInstance6acceptEP7Visitor [0xee60085] dmd/dsymbolsem.d:378 _Z15dsymbolSemanticP7DsymbolP5Scope [0xee3d538] dmd/typesem.d:2676 _ZN14ResolveVisitor5visitEP12TypeInstance [0xef1399c] dmd/mtype.d:5189 _ZN12TypeInstance6acceptEP7Visitor [0xeee1519] dmd/typesem.d:2418 void dmd.typesem.resolve(dmd.mtype.Type, ref const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.expression.Expression*, dmd.mtype.Type*, dmd.dsymbol.Dsymbol*, bool) [0xef12f1f] dmd/typesem.d:1608 _ZN19TypeSemanticVisitor5visitEP12TypeInstance [0xef113e8] dmd/mtype.d:5189 _ZN12TypeInstance6acceptEP7Visitor [0xeee1519] dmd/typesem.d:533 _Z12typeSemanticP4Type3LocP5Scope [0xef0e0b6] dmd/dsymbolsem.d:4515 pure @nogc @safe dmd.mtype.Type dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dclass.ClassDeclaration).__dgliteral2() [0xee4ba59] dmd/dsymbolsem.d:4497 dmd.mtype.Type dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dclass.ClassDeclaration).resolveBase!(dmd.mtype.Type).resolveBase(lazy dmd.mtype.Type) [0xee4e220] dmd/dsymbolsem.d:4515 _ZN22DsymbolSemanticVisitor5visitEP16ClassDeclaration [0xee49cc4] dmd/dclass.d:986 _ZN16ClassDeclaration6acceptEP7Visitor [0xee0a00d] dmd/dsymbolsem.d:378 _Z15dsymbolSemanticP7DsymbolP5Scope [0xee3d538] dmd/dtemplate.d:7427 void dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*) [0xee5ff53] dmd/dtemplate.d:7445 void dmd.dtemplate.TemplateInstance.tryExpandMembers(dmd.dscope.Scope*) [0xee5ffca] dmd/dsymbolsem.d:5671 void dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) [0xee4d3ce] dmd/dsymbolsem.d:2573 _ZN22DsymbolSemanticVisitor5visitEP16TemplateInstance [0xee443be] dmd/dtemplate.d:7474 _ZN16TemplateInstance6acceptEP7Visitor [0xee60085] dmd/dsymbolsem.d:378 _Z15dsymbolSemanticP7DsymbolP5Scope [0xee3d538] dmd/typesem.d:2676 _ZN14ResolveVisitor5visitEP12TypeInstance [0xef1399c] dmd/mtype.d:5189 _ZN12TypeInstance6acceptEP7Visitor [0xeee1519] dmd/typesem.d:2418 void dmd.typesem.resolve(dmd.mtype.Type, ref const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.expression.Expression*, dmd.mtype.Type*, dmd.dsymbol.Dsymbol*, bool) [0xef12f1f] dmd/typesem.d:1608 _ZN19TypeSemanticVisitor5visitEP12TypeInstance [0xef113e8] dmd/mtype.d:5189 _ZN12TypeInstance6acceptEP7Visitor [0xeee1519] dmd/typesem.d:533 _Z12typeSemanticP4Type3LocP5Scope [0xef0e0b6] dmd/expressionsem.d:3094 _ZN25ExpressionSemanticVisitor5visitEP6NewExp [0xee7cb92] dmd/expression.d:3171 _ZN6Ne
Re: Anonymous mapped regions increases unlimitely on spawn
So it looks like a bug, and I have reported about it: https://issues.dlang.org/show_bug.cgi?id=19487
Re: Anonymous mapped regions increases unlimitely on spawn
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?
Re: Anonymous mapped regions increases unlimitely on spawn
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; printf("detach Thread\n"); I recompiled phobos to apply changes to druntime and I see that "start Thread" there is, but "detach Thread" printed only at the end of process even if I do GC.collect(). So dtor of class Thread doesn't call on GC. Why?
Anonymous mapped regions increases unlimitely on spawn
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 regions increases on 2 every spawn process, and never decreases even after finishing the spawned thread. According to logs my program made 32543 spawns for test time. And my /proc/sys/vm/max_map_count = 65530. So only 444 maps was allocated by other reasons and 65086 by spawn. So what to do? How to make spawn decrease count of anonymous mapped regions?
Re: How to debug FinalizeError?
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) i.e. in your code, do: extern(C) void onFinalizeError(TypeInfo info, Throwable e, string file = __FILE__, size_t line = __LINE__) { import core.stdc.stdio; printf("break here\n"); } Big thanks, Steve. I will try it. Every night will do debugging and maybe at one night it will happen again :-)
Re: How to debug FinalizeError?
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 of my program looks like this: core.exception.FinalizeError@src/rt/lifetime.d(1407): Finalization error === Bypassed === BerkeleyDB exceptions mixed with output of destructors || core.exception.InvalidMemoryOperationError@src/core/exception.d(696): Invalid memory operation It means that "Invalid memory operation" occurred earlier than "Finalization error"? The line on which shows the pointer src/rt/lifetime.d(1407) is exactly: onFinalizeError(*pc, e); Why gdb doesn't see this function? My program (the text editor) had run test all night under gdb with break on InvalidMemoryOperationError and didn't fall. So it is very-very-very hard to reproduce. And I haven't ideas where maybe this throw. At least I don't see any throw in explicit form.
Re: derelict-sdl2 automatically stripping the SDL_ prefix from names
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 (module_name != "object" && module_name != __MODULE__) { mixin("import "~module_name~";"); pragma(msg, module_name~":"); foreach(member; __traits(allMembers, mixin(module_name))) { static if (__traits(compiles, mixin(member)) && (!__traits(compiles, __traits(getProtection, mixin(member))) || __traits(getProtection, mixin(member)) != "private" && __traits(getProtection, mixin(member)) != "package")) pragma(msg, member); } static if (root || module_name == "std.algorithm" || module_name == "std.range") { import std.algorithm.searching: startsWith; foreach(member; __traits(allMembers, mixin(module_name))) { static if (__traits(compiles, mixin(member)) && __traits(compiles, mixin(member).stringof.startsWith("module ")) && mixin(member).stringof.startsWith("module ")) { allMembersOfModule!(member); } } } } } As I know it worked good. Maybe it helps to you also.
How to debug FinalizeError?
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 tried "break onFinalizeError" in gdb like "break onInvalidMemoryOperationError", but it says: Function "onFinalizeError" not defined. There are too few information about this error in documentation and forum, and I didn't find anything about it in wiki. Thank you.
Re: Hacking the compiler: Get Scope after some line of function
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);
Hacking the compiler: Get Scope after some line of function
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 { ExpStatement { exp = DeclarationExp } ExpStatement { exp = DeclarationExp } ReturnStatement; } } So if I'm trying to take fbody._scope, all works correctly (other functions and templates from this module are declared), but neither a nor b are declared in this scope. But exp.declaration._scope is null. So how to get scope e.g. after line "B b;"?
Re: How to make autocompletion for IDE?
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.
Re: Cast to subclass in the dmd compiler
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: Cast to subclass in the dmd compiler
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
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", imp.packages.toChars(), imp.id.toChars()); } // ... } For really imports casting doing well. But for not imports it again casts, imp not is null and the compiler crashes. What I'm doing wrong?
Re: How to make autocompletion for IDE?
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. No, with feature like auto func() and void templ(T)(T a) if (is(a)) {} It is impossible to consider all it by myself. It means write the second compiler. So I just want to use the ready compiler.
Re: How to make autocompletion for IDE?
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 :-)
Re: How to make autocompletion for IDE?
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 Sorry, this is the right link: https://github.com/dlang-community/DCD Yes this project where "Not working: UFCS suggestions and That one feature that you REALLY needed".. I want to have all features that I really need :-) But If I will not find how do UFCS suggestions fast, I probably will use DCD for all other things..
How to make autocompletion for IDE?
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 "a".fromStringz() style instead of fromStringz(a). For it I will take editable now sources, add to it lines like this: foreach(d; __traits(allMembers, std.string)) { if (is(typeof(mixin("\"abc\"."~d~"()" pragma(msg, "\"abc\"."~d~"()" ); } So it will print all methods which can be called for strings as "abc".function(). And I want to compile this file with options "-c -o-". The problem that compilation for files with avarage count of imports may take e.g. 7 seconds.. 7 seconds is too long to wait autocompletion. But compiler really do this "task" with autocompletion requests very fast. And I think how to implement the next: Add the task to some other file task.d. import it to the first file with mixin(import("task.d")). Change syscall open() to my function which if will see that it opens "task.d" waiting the time when user will ask autocomplete (press Ctrl-space), and then write the task to "task.d" and continue execution of compiler... The problem that I see in this conception is that seems not possible write such import which will be imported only when compiler starts handle templates and simultaneously in the place where will be accessed all local variables of a function. Any ideas?
Re: Too slow readln
I understand the main problem. dirEntries by default follows symlinks. Without it my first grep works only 28.338s. That really cool!
Re: Too slow readln
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 trick and do the initial match ignoring line boundaries and correct line boundaries later. There's a good discussion in this thread ("Why GNU grep is fast" by Mike Haertel): https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html --Jon Thank you. I understand yet another trick: $ find . -exec file -bi {} + is the same $ file -bi `find .`
Too slow readln
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 result I get with ldc2.. The same with bash and grep: $ time for i in `find .`; do file -b "$i" | grep -q text && grep -a "HELLO" "$i"; done [pid 18365] write(1, "HELLO\n", 6HELLO real0m42.461s user0m23.244s sys 0m22.300s Only `file` for all files: $ time find . -exec file {} + >/dev/null real0m15.013s user0m14.556s sys 0m0.436s Only grep for all files: $ for i in `find .`; do file -b "$i" | grep -q text && echo "$i"; done > LIST1 $ time for i in `cat LIST1`; do grep -a "HELLO" "$i"; done [pid 18365] write(1, "HELLO\n", 6HELLO real0m4.431s user0m1.112s sys 0m3.148s So 15+4.4 much lesser than 42.46. Why? How "find" so fast can run "file" so many times? And why 42.461s much lesser 1m17.096s? The second version of grep: https://dpaste.dzfl.pl/9db5bc2f0a26 $ time /home/undefer/MyFiles/Projects/TEST/D/grep2 "HELLO" `cat LIST1` ./strace.log: [pid 18365] write(1, "HELLO\n", 6HELLO real0m1.871s user0m1.824s sys 0m0.048s $ time grep -a "HELLO" `cat LIST1` ./strace.log:[pid 18365] write(1, "HELLO\n", 6HELLO real0m0.075s user0m0.044s sys 0m0.028s The profiler says that readln eats CPU. So why 0m0.075s much lesser 0m1.871s? How to write in D grep not slower than GNU grep?
Re: Bad file descriptor in File destructor
Thank you. I will write if will find the reason of description corruption.
Re: Bad file descriptor in File destructor
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: Bad file descriptor in File destructor
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 is std.stdio.File. And I can't provide a minimal crashing example because this code crashes very rarely. I just want to put try/catch and don't know where to do it.
Re: Bad file descriptor in File destructor
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 because there is sometimes "Bad file descriptor" error. But now I have "Bad descriptior" in destructor. Where I must put my try/catch section to avoid it? Thank you!
Bad file descriptor in File destructor
Hello! I have the code like this: File file; try { file = File(path); } catch (Exception exp) { return; } ... try { }
Re: mkdir; remove; under Windows throw Exception
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 do whatever is easier for it in a platform-specific manner. OH, OK. Undocumented behavior is undocumented behavior...
Re: mkdir; remove; under Windows throw Exception
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: mkdir; remove; under Windows throw Exception
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 documentation says "removes the file", leaving what it does to directories undefined. Interestingly, the Linux kernel *does* make the distinction: the C remove function on Linux does a test then calls unlink or rmdir based on if it is a directory or not. But it didn't always do that. But what you have is undefined behavior - the function is only guaranteed to work on files, and does not specify if it will work or be an error on directories. Thank you, but I think in this case D must use unlink for implementation remove.
Re: mkdir; remove; under Windows throw Exception
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 wouldn't have worked an other OSes either. The problem is that you created a directory and then used a function which removes files. If you want to remove a directory, then use rmdir (or rmdirRecurse if you want to blow away a non-empty directory). - Jonathan M Davis man remove: remove - remove a file or directory The function which removes only files named unlink. The D must guarantee the same behaviour of remove on all OSes.
Re: mkdir; remove; under Windows throw Exception
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 program exits unexpectedly
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). There are cases when the console itself can crash. OK, thank you. Next time with other crashes I will try.
Re: The program exits unexpectedly
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
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 which just time created?
Re: The program exits unexpectedly
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 mini program it works and shows diagnostic message. Where my diagnostic message in more complicate program???
Re: The program exits unexpectedly
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: The program exits unexpectedly
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 infinite loop. But maybe it is unhandled signal? I have found. It exits on "stdout.flush()" Without flush falls in different places.. And in the console leaves not fully printed lines.
Re: The program exits unexpectedly
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 found. It exits on "stdout.flush()"
Re: The program exits unexpectedly
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 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?
The program exits unexpectedly
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: The order of libraries makes error in dub
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": ["/NODEFAULTLIB:LIBCMTD"]). Full correct dub.json: === { "name": "bdb2d", "targetName": "db", "targetType": "library", "description": "BerkeleyDB to D bindings.", "authors": ["Nikolay (unDEFER) Krivchenkov"], "homepage": "http://unde.su";, "license": "GPL-3.0 or later", "libs-posix": ["db"], "libs-windows-dmd": ["libdb53sd", "WS2_32"], "dflags-windows": ["-m32mscoff"], "lflags-windows": ["/NODEFAULTLIB:LIBCMTD"], "subPackages": [ { "name": "reader", "description": "BerkeleyDB Transaction test. Reader", "targetName": "reader", "targetType": "executable", "sourceFiles": ["transactions_test/reader.d"], "targetPath": "transactions_test", "dependencies": { "bdb2d": "*" } }, { "name": "writer", "description": "BerkeleyDB Transaction test. Writer", "targetName": "writer", "targetType": "executable", "sourceFiles": ["transactions_test/writer.d"], "targetPath": "transactions_test", "dependencies": { "bdb2d": "*" } } ] } Thank you to all, the thread is closed.
Re: The order of libraries makes error in dub
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: 1) Its put to linker command "db.lib" from libs-posix 2) Its put to linker command at the first "libdb53d.lib WS2_32.lib" and AFTER that -m32mscoff. As result "cannot open file".
Re: The order of libraries makes error in dub
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 must add it to subPackages, but dub places the names of lib BEFORE -m32mscoff. So it doesn't work. Say me: dub for windows not ready??
The order of libraries makes error in dub
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 Error: Error reading file 'WS_32.LIB' So it shows error. In other order (libraries at the end): $ dmd -m32mscoff -lib -of.dub\\build\\library-debug-windows-x86-dmd_2072-83D2723917096513EB360761C22DDD87\\db.lib -debug -g -w -version=Have_bdb2d -Isource source/berkeleydb/* libdb53sd.lib WS2_32.LIB -vcolumns No error. But (again WS_32.LIB at beginning): $ dmd -m32mscoff WS2_32.LIB libdb53sd.lib transactions_test/writer source/berkeleydb/* LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library Again no error, only warning. How to make with dub correct compilable compile line? my dub.json: === { "name": "bdb2d", "targetName": "db", "targetType": "library", "description": "BerkeleyDB to D bindings.", "authors": ["Nikolay (unDEFER) Krivchenkov"], "homepage": "http://unde.su";, "license": "GPL-3.0 or later", "libs-posix": ["db"], "sourceFiles-windows-dmd": ["libdb53d.lib", "WS_32.LIB"], "dflags-windows": ["-m32mscoff"], "subPackages": [ { "name": "reader", "description": "BerkeleyDB Transaction test. Reader", "targetName": "reader", "targetType": "executable", "sourceFiles": ["transactions_test/reader.d"], "targetPath": "transactions_test", "dependencies": { "bdb2d": "*" } }, { "name": "writer", "description": "BerkeleyDB Transaction test. Writer", "targetName": "writer", "targetType": "executable", "sourceFiles": ["transactions_test/writer.d"], "targetPath": "transactions_test", "dependencies": { "bdb2d": "*" } } ] } ==
Re: How to use library compiled with Microsoft Visual Studio 2015 in D?
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!
Re: How to use library compiled with Microsoft Visual Studio 2015 in D?
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 is great! But now I have the problem of unresolved external symbols, e.g. "__imp__htonl@4". What I'm doing? I'm going to Microsoft Visual Studio directory and run the script: $ for i in `/bin/find.exe . -iname "*.lib"`; do bin/dumpbin /SYMBOLS $i | /bin/grep __imp__htonl@4 && echo $i; done 308 UNDEF notype External | __imp__htonl@4 ./atlmfc/lib/nafxcw.lib 3C6 UNDEF notype External | __imp__htonl@4 ./atlmfc/lib/nafxcwd.lib 332 UNDEF notype External | __imp__htonl@4 ./atlmfc/lib/uafxcw.lib 3D6 UNDEF notype External | __imp__htonl@4 ./atlmfc/lib/uafxcwd.lib Try to link with found libraries, but it doesn't work. The symbols still unresolved. What I'm doing wrong?
How to use library compiled with Microsoft Visual Studio 2015 in D?
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) "Debug-Static" mode. I have libdb53d.lib file. Try to compile. linker say that it has unsupported COFF format. Read about COFF2OMF, buy extended utils to get it. $ coff2omf libdb53d.lib Segmentation Fault Try like on page http://www.digitalmars.com/ctg/coff2omf.html: $ link /lib /convert file.lib LINK : warning LNK4044: unrecognized option '/convert'; ignored So nothing works. How to use a library compiled with Microsoft Visual Studio 2015 in D?
Re: Delegates: Print 0..9
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!
Re: Delegates: Print 0..9
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); } return &print; } functions ~= get_print(i); } foreach (i; 0..10) { functions[i](); } } = Thank you!
Delegates: Print 0..9
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 ~= &print; } foreach (i; 0..10) { functions[i](); } } = Prints $ ./delegates.d 9 9 9 9 9 9 9 9 9 9 How to print 0..9?