Re: GetInterfaceInfo function of win32 api
On Thursday, 8 June 2023 at 07:01:44 UTC, Benny wrote: this got me 122 don be shy, try to do something yourself, be curiosity! use C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\errlook.exe or https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- to find what means some error code
Re: How hide console in dub.sdl under windows 11?
On Thursday, 25 May 2023 at 08:37:40 UTC, John Xu wrote: For dmd, I can use a no_console.def file, which has: EXETYPE NT SUBSYSTEM WINDOWS Then `dmd my.d no_console.def` to hide console. But how do I realize it with dub.sdl ? Adding no_console.def to "sourceFiles", doesn't help. redirect to nul? ```command -args >nul 2>&1```
Re: ImportC for libuv
On Wednesday, 24 May 2023 at 18:49:02 UTC, a11e99z wrote: someone might find it interesting how to use ImportC in life: [https://issues.dlang.org/show_bug.cgi?id=23935](https://issues.dlang.org/show_bug.cgi?id=23935) ADD pragma pack issue [https://issues.dlang.org/show_bug.cgi?id=23936](https://issues.dlang.org/show_bug.cgi?id=23936)
member func is best choice for pointers?
```d import std, core.lifetime; struct Node { Node* pNext; void func() { "Node::func %s".writeln( pNext); } } void func( Node* p ) { "::func %s(%s)".writeln( p, p == null ? p : p.next); } void main() { Node n; auto pn = &n; //cast( Node* )0; pn.func(); // prints: Node::func // WTF? // why called Node::func for Node* when ::func is right choice for it? } ``` problem: member func has invariant that **this** is not null (programmer thinks so). global func hasn't the one and programmer should check for it before doing something. when pn is null u've got AccessViolation/Signal_11 with no stacktrace. workaround: avoid overloaded UFCS for pointers
Re: Example of Windows SSL with Secure Channel?
On Saturday, 19 March 2022 at 16:54:03 UTC, Anonymouse wrote: Does anyone have an example snippet code connecting to, reading from and writing to a server using SSL under Windows with Secure Channel? Something in a personal project you wouldn't mind sharing a part of to let me dissect? https://www.amazon.com/Programming-Server-Side-Applications-Microsoft-Windows/dp/0735607532 You can download example for it: SslChat
Re: 200-600x slower Dlang performance with nested foreach loop
On Sunday, 31 January 2021 at 16:50:15 UTC, methonash wrote: What confuses me, at this point, is this: I originally wrote the D code using foreach in this style: foreach( i, ref parentString; strings ) foreach( j, ref childString; strings[ i + 1 .. $ ] ) Essentially, the value of j printed to stdout should always be larger than the value of i. j is counted from current begginning: from 0 strings[i+1..$][0] - its right behaviour
Re: Garbage Collection Issue
On Sunday, 31 May 2020 at 16:57:06 UTC, Steven Schveighoffer wrote: I can't imagine much of druntime working at all without TLS. Indeed, it is a requirement these days. TLS is evil for async/await when any thread can execute any fiber (case where fiber tied to thread is wrong/dead version of async/await cuz 1st thread has 1000 fibers and 2nd only 10)
Re: want to know precise GC benchmarks
On Wednesday, 2 October 2019 at 06:41:28 UTC, Rainer Schuetze wrote: thanks for the detailed answer
Re: want to know precise GC benchmarks
On Tuesday, 1 October 2019 at 16:12:18 UTC, a11e99z wrote: does anybody some kind of benchmark to test conservative and precise GC? precise GC is better or not? is STW improving? and another question about GC and app parameters: program.exe “–DRT-gcopt=gc:precise parallel:4” “–DRT-scanDataSeg=precise” output.data are this 2 -DRT params combined or overwriting each other? link to doc for DRT+GC https://dlang.org/spec/garbage.html#gc_config I know about rt_options[] but asking about program args why I want to know such info? CodinGame sometimes use time-limit for bot move for example 100ms, and bot will be disqualified in case no answer
want to know precise GC benchmarks
does anybody some kind of benchmark to test conservative and precise GC? precise GC is better or not? is STW improving?
Re: Packaging and Distributing Dlang Applications with GtkD Dependency?
On Wednesday, 25 September 2019 at 12:04:16 UTC, Ron Tarrant wrote: On Wednesday, 25 September 2019 at 11:50:58 UTC, a11e99z wrote: On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant wrote: Hi y'all, What I'm looking for is a system for bundling dlang apps and their dependencies for distribution to end users. Hopefully, this bundler will: - install the app in an appropriate place (like C:\Program Files\, - install libraries/dependencies (such as GtkD) also in an appropriate place, - make any modifications to the system PATH that may be necessary for the app to run, and - handle any other roadblocks that will keep the user from using the app. Similarly, on Linux or other UNIX-alikes, a breakdown of how to use apt or something similar to do the same so the user can (for instance) just do: apt-get to install. so u need installers/installation program https://en.wikipedia.org/wiki/List_of_installation_software well, a long-long time ago I used InstallShield & Wix Toolset for Windows only. I know no one that works with Linux package systems.
Re: Packaging and Distributing Dlang Applications with GtkD Dependency?
On Wednesday, 25 September 2019 at 11:46:04 UTC, Ron Tarrant wrote: Hi y'all, I've been Googling how to do this, but coming up with nothing definitive. Are there any articles for how to do this for: Windows? Linux? other UNIX-alike OSs? UPX? https://en.wikipedia.org/wiki/UPX https://linux.die.net/man/1/upx
Re: How to force an array literal into a read-only data segment?
On Thursday, 12 September 2019 at 07:04:19 UTC, Max Samukha wrote: How to achieve the same for an array literal? The closest I could come: enum immutable(int[3]) _tmp = [1, 2, 3]; __gshared a = _tmp.ptr; Is it possible to force the array into rodata? https://p0nce.github.io/d-idioms/#Precomputed-tables-at-compile-time-through-CTFE static immutable(int[3]) _tmp = [1, 2, 3]; ?
Re: LDC asm for int128
On Tuesday, 10 September 2019 at 06:18:05 UTC, Newbie2019 wrote: I want to translate this c code into d (build with ldc), so I can use -flto and inline with other code. uint64_t _wymum(uint64_t A, uint64_t B){ __uint128_t r = A ; r *= B; return (r>>64)^r; } Do i need ASM or is there a easy way to implement it ? https://forum.dlang.org/post/ighiwexofvdqbuqeq...@forum.dlang.org
Re: It there a way to get this to compile?
On Monday, 9 September 2019 at 19:08:17 UTC, WhatMeWorry wrote: struct FoundationPile { Card[] up;// all cards are face up on the Foundation } FoundationPile[4] foundations; static if(true) { int r = 2; int c = 40; static foreach(i ; foundations) { immutable string brackets = "\033[" ~ to!string(r) ~ ";" ~ to!string(c) ~ "H"; c = c + 10; // line 155 } } NB dont use name "i" for foreach/ranges, foreach can be used with index too, use "el" as "element" or "it" as "iterator" or just "something" static if(true) { enum r = 2, c = 40; // bad names too static foreach( idx, el; foundations) { immutable string brackets = "\033[" ~ to!string(r) ~ ";" ~ to!string(c + idx*10) ~ "H"; } }
Re: Throwing from a lambda isn't supported by the compiler
On Monday, 9 September 2019 at 09:14:08 UTC, Andre Pany wrote: I noticed, that I cannot throw from the lambda expression: Error: expression expected, not throw but have to use the longer syntax () {throw new Exception();} --- void foo(void function() e){} void main() { foo( () => throw new Exception() ); } --- The shorter lambda syntax would be more readable in my case. Is there a reason why it isn't allowed or should I create an enhancement request? and next code too. C# code good is it int func( bool ok ) { return ok ? 123 : throw new Exception( "oops 123"); } cuz throwing exception ever is not compatible with any return type so I dont see reasons do not allow such expressions
Re: C++ vs D: Default param values and struct to array casting
On Friday, 6 September 2019 at 09:14:31 UTC, Andrew Edwards wrote: C++ allows the for following: struct Demo { float a, b, c, d; Demo() { a = b = c = d = 0.0f; } Demo(float _a, float _b, float _c, float _d) { a = _a; b = _b; c = _c; d = _d; } float operator[] (size_t i) const { return (&a)[i]; } //[3] float& operator[] (size_t i) { return (&a)[i]; } //[4] } https://dlang.org/spec/simd.html also probably u can do https://run.dlang.io/is/WMQE93
Re: How stdin.readf ignore space char?
On Tuesday, 3 September 2019 at 13:25:30 UTC, lili wrote: On Tuesday, 3 September 2019 at 13:21:16 UTC, a11e99z wrote: On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote: string d = "3.43.3 "; double a; double b; //formattedRead(d,"%f %f", &a, &b); d.readf!" %s %s"(a,b);//hug writeln(a,b); and this too string ds = "1.1 2.2 3.3"; double[] darr; ds.formattedRead!"%( %s%)"( darr ); darr.writeln;
Re: How stdin.readf ignore space char?
On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote: Hi guys: input is two line, first line is a number n and second line is n float point number, e.g. 3 1.1 2.2 3.3 how use stdin.readf get all number. u can read array this way too auto darr = readln.split.map!(x => x.to!double).array; darr.writeln;
Re: How stdin.readf ignore space char?
On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote: Hi guys: input is two line, first line is a number n and second line is n float point number, e.g. 3 1.1 2.2 3.3 how use stdin.readf get all number. https://dlang.org/library/std/stdio/readf.html see example
Re: Deactivate windows MessageBox dialog on exception
On Wednesday, 28 August 2019 at 12:19:54 UTC, Andre Pany wrote: Hi, I call another process using function pipeShell and Redirect.all. import std; void main() { auto p = pipeShell("a.exe", Redirect.all); p.stdin.writeln("e1"); p.stdin.writeln("10"); p.stdin.writeln("e2"); p.stdin.writeln("9"); p.stdin.flush(); p.stdout.readln.writeln; import core.thread: Thread; import core.time: seconds; Thread.sleep(2.seconds); p.stdin.close; p.stderr.byLineCopy.writeln; Thread.sleep(1.seconds); try { p.pid.kill; // Windows exception here "Access denied" p.pid.wait; // but no more MessageBox } catch (Throwable) { } }
Re: Deactivate windows MessageBox dialog on exception
On Wednesday, 28 August 2019 at 12:19:54 UTC, Andre Pany wrote: and try to use https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode SEM_FAILCRITICALERRORS for mother process and child process will inherit it
Re: Deactivate windows MessageBox dialog on exception
On Wednesday, 28 August 2019 at 12:19:54 UTC, Andre Pany wrote: Hi, I call another process using function pipeShell and Redirect.all. In case the child process(also D application) throws an exception (str to int conversion exception), the child process shows a message box on windows. 1) mother process "b" shouldn't terminates/close_pipes early than "a" cuz lines 690 checks stderr is valid, if no then MessageBox is showing. 2) if "a" is wrong or hang just terminate it, result already known. 3) also u can try redirect not all pipes just stdout/stdin, stderr for "a" probably will be working to mother console.
Re: Sort Associative Array by Key
On Tuesday, 27 August 2019 at 20:35:16 UTC, bachmeier wrote: On Tuesday, 27 August 2019 at 20:14:21 UTC, Machine Code wrote: It isn't really hard: It really is hard. foo.byPair.array.sort!((a, b) => a.key < b.key).map!(a => a.value); is a lot to digest for someone learning the language. There's a big difference between not being hard for someone that understands what each piece does and not being hard for someone new to D. At a minimum, it would help to write it foo.byPair .array .sort!((a, b) => a.key < b.key) .map!(a => a.value); I wrote expression with string lambdas for one purpose: when u see very simple beauty thing that is working and u totally doesn't understand how exactly, ur curiosity should do the rest of the work. it's worth sorting out. if man wanted just do his job, he got this too.
Re: Input/Output multiple values from function
On Wednesday, 28 August 2019 at 05:17:28 UTC, Jabari Zakiya wrote: On Wednesday, 28 August 2019 at 04:39:23 UTC, Mike Parker wrote: On Wednesday, 28 August 2019 at 04:19:49 UTC, Jabari Zakiya wrote: I have a function (say func1) that takes 1 input value (an integer number) and outputs 4 values (2 integers and 2 arrays of integers). Then inside another function (say func2) I provide the 1 input to func1 and then want to assign its 4 output values to their appropriate final variables that will use them. https://dlang.org/library/std/typecons/tuple.expand.html ?
Re: stdin/stdout and flush
On Tuesday, 27 August 2019 at 21:01:58 UTC, Andre Pany wrote: On Tuesday, 27 August 2019 at 20:45:44 UTC, a11e99z wrote: On Tuesday, 27 August 2019 at 20:09:34 UTC, Andre Pany wrote: "b" should send data in loop too, then "a" will work ok. do u still hack CodinGame? :)
Re: stdin/stdout and flush
On Tuesday, 27 August 2019 at 21:28:05 UTC, a11e99z wrote: On Tuesday, 27 August 2019 at 21:01:58 UTC, Andre Pany wrote: On Tuesday, 27 August 2019 at 20:45:44 UTC, a11e99z wrote: On Tuesday, 27 August 2019 at 20:09:34 UTC, Andre Pany wrote: what result u expecting? then u send from "b" p.stdout.readln(); that is read as 2nd its not sent, "b" just read from pipe pipe closed and null (no data) come to "a"
Re: stdin/stdout and flush
On Tuesday, 27 August 2019 at 21:01:58 UTC, Andre Pany wrote: On Tuesday, 27 August 2019 at 20:45:44 UTC, a11e99z wrote: On Tuesday, 27 August 2019 at 20:09:34 UTC, Andre Pany wrote: what result u expecting? u send from "b": e1 10 e2 9 "a" read it. 1st loop finished. then u send from "b" p.stdout.readln(); that is read as 2nd enemy1=null and finally sleep and exit from b.main where pipe is closed and "a" read null again (no data) dist1 = null.to!int => error
Re: stdin/stdout and flush
On Tuesday, 27 August 2019 at 20:09:34 UTC, Andre Pany wrote: This applications will be called by a second application: import std; void main() { auto p = pipeShell("a", Redirect.all); p.stdin.writeln("e1"); p.stdin.writeln("10"); p.stdin.writeln("e2"); p.stdin.writeln("9"); p.stdin.flush(); p.stdout.readln(); } In application a.d the first "while round" will succeed as expected. But in the second "while round" the readln does not wait until there is an input but gets an empty string. The to!int will therefore throw an exception. Why does the readln returns an empty string in the second run and does not wait on an input? probably cuz no second "send round" in b.d. or u mean second half-round "e2,9"?
Re: Structure of Arrays vs Array of Structures
On Monday, 26 August 2019 at 09:58:30 UTC, Per Nordlöw wrote: On Monday, 26 August 2019 at 09:54:30 UTC, Per Nordlöw wrote: I have made some significant optimizations with regards to compilation performance at https://github.com/nordlow/phobos-next/blob/master/src/soa.d What is the preferred way to implement to support foreach over `x` in struct S { int i; float f; } auto x = SOA!S(); foreach (S; x[]) { } ? Implement `opSlice` that returns a SOA.Range type? 1) not sure about opSlice cuz user can allocate every time when he need S[..] from SOA. easy call for user but its too expensive op. maybe better to define global array( T )( SOA!T {opt: int beg, int end}) that returns array. x.array or array( x ) or x.array( 10, 20) looks like DRT that means "some range to newly allocated array". and SOA to S is some calculated range - need construct each element. 2) x.items returns SOA.Range
Re: .fflush() in stdio.d
On Monday, 26 August 2019 at 09:14:23 UTC, Jonathan M Davis wrote: On Sunday, August 25, 2019 11:59:08 PM MDT berni via - Jonathan M Davis OFFTOPIC: (dont have ur email. dont like emails cuz too officially and too long) (and dont want create new topic. this one probably solved/finished already) about benchmark https://dlang.org/library/std/datetime/stopwatch/benchmark.html idk all reason why that not vice versa but imo better to change: for now: Duration[3] benchmark!(f1, f2, f3)( int runCount ); remarks: benchmark!( // next is simple func list () => ps.each!( p => b += gcd( p[0], p[1])), () => ps.each!( p => a += divGCD( p[0], p[1])), )( 10 ) // and here real call with complicated number .array // without it .map! is not compiling .map!( x => x.total!"msecs") .writeln; 1) .map! for static arrays doesn't compiling maybe better to return Range? 2) code with benchmark!() looks turn upside down when u try to use lambdas as args I suggest add another versions of benchmark: auto bench!( int N, FuncList...)( FuncList funcs ); benchmark!10( () => ps.each!( p => b += gcd( p[0], p[1])), () => ps.each!( p => a += divGCD( p[0], p[1])))... auto bench!( FuncList...)( int N, FuncList funcs ); benchmark( 10, () => ps.each!( p => b += gcd( p[0], p[1])), () => ps.each!( p => a += divGCD( p[0], p[1])))...
Re: Sort Associative Array by Key
On Sunday, 25 August 2019 at 16:54:33 UTC, Samir wrote: Is there a way to output the values of an associative array based on the lexicographic order of the keys? For example, if foo = ["VXE":8, "BZP":5, "JLC":2], I'd like to output something like: 5 2 8 auto foo = ["VXE":8, "BZP":5, "JLC":2]; foo.byPair.array.sort!"a[0]
Re: [Help!] Use two different assembly symbol in D, but they are same address.
On Sunday, 25 August 2019 at 13:43:42 UTC, a11e99z wrote: On Sunday, 25 August 2019 at 13:24:57 UTC, lili wrote: On Saturday, 24 August 2019 at 12:55:57 UTC, a11e99z wrote: and try to use any compiler DMD/LDC/GDC. maybe result will be that u want.
Re: [Help!] Use two different assembly symbol in D, but they are same address.
On Sunday, 25 August 2019 at 13:24:57 UTC, lili wrote: On Saturday, 24 August 2019 at 12:55:57 UTC, a11e99z wrote: On Saturday, 24 August 2019 at 12:16:34 UTC, lili wrote: On Saturday, 24 August 2019 at 12:09:19 UTC, a11e99z wrote: On Saturday, 24 August 2019 at 11:53:01 UTC, lili wrote: [...] resb 8 just reserving 8 bytes not initializing it. probably u compare some garbage. sometimes it equals, sometimes not. no? I write wrong, not if (_vga_x == _vga_y) but if (&_vga_x == &_vga_y) try to do next: add funtion in asm that returns real addresses to vga_x,y extern(C) void asmVgas( int** px, int** py) call it int *px, *py; asmVgas( &px, &py); writefln( "%s=%s,%s=%s",px, &_vga_x,py, &_vga_y); and see result I followed your suggest, call asm_fn in d function. it return address not 0 but is a correct address same as the var address show in link map file. when a try define a __shared int xx, the &xx also 0. after linked all variables address is 0 that in .bss segment. do you know why occur this? [global asm_fn] asm_fn: mov rax, p2_table ret no idea. u can to define _vga_x,_vga_y in D code and export it to asm (vice versa than now). see result again. in case still not working: make very simple app with global vars: 2 D-files OR 1 D-file and 1 asm-file (maybe its not working even for D+D files). try to get same bug from compiler/linker. fill the issue and attach both files as sample. add point (for case D+asm) "how to compile asm file for linking with D" as u did. then wait and hope.
Re: Merging two associative arrays
On Saturday, 24 August 2019 at 19:35:25 UTC, berni wrote: I've got two associative arrays and want to get a new one, which is created out of both of them: This works: string[int] a = [1:"one", 7:"seven"]; string[int] b = [5:"five", 9:"nine"]; string[int] tmp = a.dup; foreach (k,v;b) tmp[k] = v; assert(tmp==[1:"one", 7:"seven", 5:"five", 9:"nine"]); But is there something easier, especially without making that "tmp" explicit. I hoped for a~b, but that didn't work. (I allready know, that there aren't duplicated keys, if that matters.) auto ab = a.byPair.chain( b.byPair).assocArray ?
Re: [Help!] Use two different assembly symbol in D, but they are same address.
On Saturday, 24 August 2019 at 12:16:34 UTC, lili wrote: On Saturday, 24 August 2019 at 12:09:19 UTC, a11e99z wrote: On Saturday, 24 August 2019 at 11:53:01 UTC, lili wrote: [...] resb 8 just reserving 8 bytes not initializing it. probably u compare some garbage. sometimes it equals, sometimes not. no? I write wrong, not if (_vga_x == _vga_y) but if (&_vga_x == &_vga_y) try to do next: add funtion in asm that returns real addresses to vga_x,y extern(C) void asmVgas( int** px, int** py) call it int *px, *py; asmVgas( &px, &py); writefln( "%s=%s,%s=%s",px, &_vga_x,py, &_vga_y); and see result
Re: [Help!] Use two different assembly symbol in D, but they are same address.
On Saturday, 24 August 2019 at 11:53:01 UTC, lili wrote: Hi: definition _vga_x and _vga_y symbol in asm, compile use nasm -f elf64 -o boot.o boot.asm [section .bss] ... [global _vga_x] _vga_x: resb 8 [global _vga_y] _vga_y: resb 8 and nm boot.o show below ... 00107000 B _vga_x 00107008 B _vga_y and In another D file use this two symbol extern(C) { extern __gshared int _vga_x; //definition in boot.asm extern __gshared int _vga_y; //definition in boot.asm } void tt() { if (_vga_x == _vga_y) //where is true, why? } but when a run tt so strange things happend that the test is true. Is where has a coding mistake. src https://github.com/lilijreey/OS-D resb 8 just reserving 8 bytes not initializing it. probably u compare some garbage. sometimes it equals, sometimes not. no?
Re: D1: Trying to update Juno Library to 1.076
On Friday, 23 August 2019 at 17:50:52 UTC, jicman wrote: On Friday, 23 August 2019 at 17:18:55 UTC, a11e99z wrote: On Friday, 23 August 2019 at 17:03:24 UTC, jicman wrote: On Friday, 23 August 2019 at 16:49:07 UTC, a11e99z wrote: right now problem exists with linker/libs only, compiler see another try: zip ur dmd 1.076 folder (for easy restoring it when something go wrong) copy lib files from 1.046\lib\*.lib to 1.076\lib\*.lib try to compile program again with dmd 1.076 TA-DAH! Weird stuff. The 1.046 libraries worked. Very weird stuff. Now to try to figure out how that happened, since I took **all** 1.076 from the download site. Which means, that it may be have outdated libraries. That's for another day, though. Muchas gracias, as we say in Spanish. But, I'll translate for you, Thanks very much. josé oops! better to restore 1.076 back and copy only Windows libs (not all DRT and others) one by one till compilation errors dissapear: oleaut32.lib ole32.lib rpcrt4.lib ...
Re: D1: Trying to update Juno Library to 1.076
On Friday, 23 August 2019 at 17:03:24 UTC, jicman wrote: On Friday, 23 August 2019 at 16:49:07 UTC, a11e99z wrote: right now problem exists with linker/libs only, compiler see all used VarXXX First of all, thanks for your patient support. to the above program, and still fails with the same error. I also went and downloaded the latest D1 linker, and that also results in the same failure. another try: zip ur dmd 1.076 folder (for easy restoring it when something go wrong) copy lib files from 1.046\lib\*.lib to 1.076\lib\*.lib try to compile program again with dmd 1.076
Re: D1: Trying to update Juno Library to 1.076
On Friday, 23 August 2019 at 16:09:16 UTC, jicman wrote: On Friday, 23 August 2019 at 16:02:38 UTC, a11e99z wrote: On Friday, 23 August 2019 at 16:00:00 UTC, a11e99z wrote: On Friday, 23 August 2019 at 14:02:36 UTC, jicman wrote: On Thursday, 22 August 2019 at 19:59:55 UTC, jicman wrote: cuz I tried compile app void main() { VARIANT a, b; VarCmp( &a, &b, 0, 0).writeln; } with DMD for x86/m32 & x64/m64 and I also failed but LDC can compile for x64 (x86 its failed too but probably cuz my ENV setupped for x64) if somebody will try to compile that whole D-code for testing import std, core.sys.windows.oaidl, core.sys.windows.oleauto; void main() { VARIANT a, b; VarCmp( &a, &b, 0, 0 ).writeln; } That looks like D2 code. I am trying to compile D1 code. I think the linker is not getting something right. right now problem exists with linker/libs only, compiler see all used VarXXX u can download LDC (if it exists) for D1 and try to compile program for D1 import std.stdio; // i dont know right Windows modules for D1 so import what u have void main() { VARIANT a, b; VarCmp( a, b, 0, 0 ); // D1 version cuz was VarCmp( ref VARIANT, ... ) }
Re: D1: Trying to update Juno Library to 1.076
On Friday, 23 August 2019 at 16:00:00 UTC, a11e99z wrote: On Friday, 23 August 2019 at 14:02:36 UTC, jicman wrote: On Thursday, 22 August 2019 at 19:59:55 UTC, jicman wrote: cuz I tried compile app void main() { VARIANT a, b; VarCmp( &a, &b, 0, 0).writeln; } with DMD for x86/m32 & x64/m64 and I also failed but LDC can compile for x64 (x86 its failed too but probably cuz my ENV setupped for x64) if somebody will try to compile that whole D-code for testing import std, core.sys.windows.oaidl, core.sys.windows.oleauto; void main() { VARIANT a, b; VarCmp( &a, &b, 0, 0 ).writeln; }
Re: D1: Trying to update Juno Library to 1.076
On Friday, 23 August 2019 at 14:02:36 UTC, jicman wrote: On Thursday, 22 August 2019 at 19:59:55 UTC, jicman wrote: I think I have figured out what is going on. I will comeback, if I need more help, but I have to rewrite a few more functions. But, thanks for pointing out the pragma. That gave me an idea of what was going on. can u try to compile with LDC? cuz I tried compile app void main() { VARIANT a, b; VarCmp( &a, &b, 0, 0).writeln; } with DMD for x86/m32 & x64/m64 and I also failed but LDC can compile for x64 (x86 its failed too but probably cuz my ENV setupped for x64)
Re: D1: Trying to update Juno Library to 1.076
On Thursday, 22 August 2019 at 16:59:03 UTC, jicman wrote: On Thursday, 22 August 2019 at 16:36:45 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:34:52 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:34:06 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:07:00 UTC, jicman wrote: On Thursday, 22 August 2019 at 15:58:56 UTC, a11e99z wrote: case of string doesn't matter for Windows. I mean for command lines (not in D code) and again I mean: file names are case insensitive fro Windows :) Thanks. ;-) Any specific one? I am trying -debug, and it is giving me the same thing. If I try -w, just gives me too many warnings. Error 42: Symbol Undefined _VarDecNeg@8 These are the options for dmd 1.076: -v verbose
Re: D1: Trying to update Juno Library to 1.076
On Thursday, 22 August 2019 at 16:34:52 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:34:06 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:07:00 UTC, jicman wrote: On Thursday, 22 August 2019 at 15:58:56 UTC, a11e99z wrote: case of string doesn't matter for Windows. I mean for command lines (not in D code) and again I mean: file names are case insensitive fro Windows :)
Re: D1: Trying to update Juno Library to 1.076
On Thursday, 22 August 2019 at 16:34:06 UTC, a11e99z wrote: On Thursday, 22 August 2019 at 16:07:00 UTC, jicman wrote: On Thursday, 22 August 2019 at 15:58:56 UTC, a11e99z wrote: case of string doesn't matter for Windows. I mean for command lines (not in D code)
Re: D1: Trying to update Juno Library to 1.076
On Thursday, 22 August 2019 at 16:07:00 UTC, jicman wrote: On Thursday, 22 August 2019 at 15:58:56 UTC, a11e99z wrote: try to add pragma( lib, "OleAut32.lib" ) Thanks for the support, a11e99z. :-) I have, pragma(lib, "ole32.lib"); pragma(lib, "oleaut32.lib"); on that file. But I did go change it back to your suggestion, pragma(lib, "ole32.lib"); pragma(lib, "OleAut32.lib"); and still get same error: Thoughts? thanks. case of string doesn't matter for Windows. so if u had "oleaut32" not working then "OleAut32" also will not work. try to turn on verbose compilation and see all commands that generated by dub/compiler
Re: D1: Trying to update Juno Library to 1.076
On Thursday, 22 August 2019 at 15:55:48 UTC, jicman wrote: Greetings! I have been working on Juno for a long time with D1 version 1.046, and love it. But now, I want to update it to 1.076, the latest and greatest D1. I have fixed, what I think, were all of the problems. However, when I build the libraries with my program, I get this error: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html c:\D\import\juno\com\core.obj(core) Error 42: Symbol Undefined _VarCmp@16 c:\D\import\juno\com\core.obj(core) Error 42: Symbol Undefined _VarDecNeg@8 The D1 version is, DMD32 D Compiler v1.076 Any thoughts of what to do next? Thanks. try to add pragma( lib, "OleAut32.lib" )
Re: What is "dmd" Internal API, can I use it just like std Library Reference?
On Tuesday, 20 August 2019 at 12:52:31 UTC, BoQsc wrote: Hello everyone, again, I had an idea that I want some colors in the output of Command Line (For Windows) and the Terminal (For Linux) yesterday was talks about terminal colors in IRC-channel: u can use VT-codes for changing colors: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#text-formatting probably for Win10 only. idk for which Linux/Terminals it working too // Windows code import std, core.sys.windows.windows; void main() { auto hc = GetStdHandle( STD_OUTPUT_HANDLE ); assert( hc != INVALID_HANDLE_VALUE); uint mod; auto ok = GetConsoleMode( hc, &mod); assert( ok); ok = SetConsoleMode( hc, mod | ENABLE_VIRTUAL_TERMINAL_PROCESSING ); assert( ok); writeln( "\x1b[38;2;255;100;0mTRUECOLOR"); writeln( "\x1b[30;47mHello from Inversed" ); writeln( "\x1b[38;2;255;0;255mTRUECOLOR\x1b[0m" ); // last "\x1b[0m" - make colors default readln; }
Re: Can't add a const ubyte to a dynamic array of ubyte?
On Tuesday, 20 August 2019 at 09:49:21 UTC, Daniel Kozak wrote: On Tue, Aug 20, 2019 at 11:30 AM ads via Digitalmars-d-learn wrote: you do not allow a person to think about a problem (and it’s easy here). you carried him through a puddle now, but when he dives into Sea D, you will not be there :)
Re: Can't add a const ubyte to a dynamic array of ubyte?
On Tuesday, 20 August 2019 at 09:27:36 UTC, ads wrote: import std.stdio; ubyte[] extend(in uint[] arr) { ubyte[] result; foreach (n; arr) { if (n < 10) result ~= n; else { import std.conv : to; foreach (digit; n.to!string) result ~= digit.to!ubyte; } } return result; } unittest { import std.algorithm : equal; assert(extend([1, 25, 70, 0]).equal([1, 2, 5, 7, 0, 0])); } How can I get around this? I want to ensure that the array is not mutated in the function in the signature too. what u using here? result ~= digit.to!ubyte; why not to do same in line? result ~= n; 2) digit is '0'+(0..9) so u need subtract '0' ('0' is \x30)
Re: Why is this allowed? Inheritance variable shadowing
On Tuesday, 13 August 2019 at 06:39:24 UTC, a11e99z wrote: On Tuesday, 13 August 2019 at 05:57:23 UTC, Mike Parker wrote: On Tuesday, 13 August 2019 at 04:40:53 UTC, Chris Katko wrote: OT: and again how to easy to google info about error/warning just with one word "CS0108" D can use attrs for such things. OT: 1) need to add compiler attrs that speaks with compiler - they are change code generation, compiler passes or something. like pragmas do. 2) need to separate all attrs in a separate construction like C# do [inline, nextOne, returns: someAttrToReturnValue] int meth( [argAttrCanBeToo] int x ) { } or [hide] public int x = 2; cuz its visually separated and easy to skip it with eye when u reading/reviewing code. it can be mess for now: pure @trusted int meth( int x ) @nogc nothrow { return 5; } NB all of this attrs is compiler attrs not user, they changes compilation. - no possibility add attr to args or returns - some attrs with "@" and some don't - its hard to read when D adds 2-3 attrs more for next 5-10 years my wishlist of new compilation attrs: - [hiding] for subj - [offset(N)] for explicit struct alignment without mess with unions/align(4) cuz sometimes I know exactly offset for field and I can point it with no side effects calcs adding pads, unions and etc - [inline(bool)] instead of pragma( inline, true ) that looks like compiler attr but another way - [deprecated(text)] - [nodiscard] cannot discard return value - etc
Re: Why is this allowed? Inheritance variable shadowing
On Tuesday, 13 August 2019 at 05:57:23 UTC, Mike Parker wrote: On Tuesday, 13 August 2019 at 04:40:53 UTC, Chris Katko wrote: I don't know if I'd call that shadowing. This is how it works in Java, too. There's no such thing as a vtable for member variables -- each class gets its own set and they don't conflict. The only time it could be really be called shadowing is when the base class member is protected, as then it's accessible in the subclass scope. Also, it's not the same thing as overriding. Overriding means that when you call base.foo(), you get sub.foo()'s implementation. But when you access base.var, you get base.var and not sub.var. I would find it extremely annoying if it worked the way you're expecting it to. C# results: main.cs(8,14): warning CS0108: `B.x' hides inherited member `A.x'. Use the new keyword if hiding was intended main.cs(4,14): (Location of the symbol related to previous warning) Compilation succeeded - 1 warning(s) mono main.exe 1 2 with "new" keyword that is used to hide a method, property, indexer, or event of the base class into the derived class. class B : A { public new int x = 2; // I tell "I want hiding. Ensure "x exists in parent"" explicitly // almost same meaning as "override" } OT: and again how to easy to google info about error/warning just with one word "CS0108"
Re: Ethan: About your wpf/C# and D integration
On Monday, 12 August 2019 at 13:08:17 UTC, Bert wrote: One of the biggest issues I have with D is properly gui development. It's just a real pain in the ass compared to wpf and C#. maybe it is better to use WinRT instead of C#/WPF? - can be used for desktop apps too - same XAML - WinRT based on COM-model so it can be simpler interop (not sure how to transfer POD types. maybe streaming?) - no need pinning from CLR side - definitions can be generated from WinMD metadata files
Re: What the abstrac final class mean?
On Monday, 12 August 2019 at 09:16:19 UTC, Alex wrote: On Monday, 12 August 2019 at 08:54:56 UTC, lili wrote: Hi: Why need defined an abstract final class? see https://github.com/Rikarin/Trinix/blob/master/Kernel/arch/amd64/gdt.d From what I saw, all members are static. So, this is a kind of utility class, which is not supposed to be instantiated, nor to be derived from. Maybe, it serves like a namespace, for convenience... its weird that next compiles in some weird form import std; static class A { static a() { "a".writeln; } // forgot return type } void main() { A.a(); A b, c; // 2 instances with diff addr "%s %s".writefln( &b, &c ); } // and for static struct DMD gives to A size 1b, LDC - 8b
Re: Module static constructor doesn't work?
On Thursday, 8 August 2019 at 14:55:37 UTC, Andrey Zherikov wrote: I have the following code: // main.d int main() { import std.stdio; writeln("hello"); return 0; } But if I create library from lib.d first and then link it with main.d then ctor/dtor are not called: $ dmd.exe -lib lib1/lib.d -od=lib1 $ dmd.exe main.d lib1/lib.lib && main.exe hello try to add to main.d: import lib1.lib;
Re: Help me decide D or C
On Thursday, 1 August 2019 at 15:17:11 UTC, a11e99z wrote: On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote: Hi everyone, I would like an honest opinion. I have a beginner level (able to do very small programs) in a few languages such as python, go, C, guile(scheme) and common lisp. I want to pick a language and go deep with it and focus on only one for at least the next 2 years or so. program bouncing ball on few languages and choose that more liked. learning language with numbers and strings only is boring. also you can program tasks from https://www.codingame.com/training/easy with dozen languages in web browser before install to local machine. some of them contains graphics https://www.codingame.com/ide/puzzle/power-of-thor-episode-1 when u run tests. read data from stdin, print result to stdout, and use stderr for debugging with diagnostics messages. imo better choice is (with criteria to find best job) - Qt: C++ with any library that u need in one style - C#: web, graphics, mobiles, command tools with nice language. - Java/Kotlin: same as C# but in top-3. C# is top-5 with more comfort language than Java. Kotlin same comfort as C#, but JVM (Virtual Machine of Java and Kotlin) still does not support value types, that is sucks. - JavaScript/TypeScript: web-browser language with node.js that allows to program server side too. - You can try Python too. another dynamic language (as JavaScript). I don't like langs that based on space/tabs so I can not say anything about it. C is too low level language. and many resources is not best criteria for it. (like people says "there's definitely something in the shit, a million flies can't be wrong"). D is stuck in some middle ages with subsistence economy, they still have stone tools but now they found iron/steel :)
Re: Help me decide D or C
On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote: Hi everyone, I would like an honest opinion. I have a beginner level (able to do very small programs) in a few languages such as python, go, C, guile(scheme) and common lisp. I want to pick a language and go deep with it and focus on only one for at least the next 2 years or so. program bouncing ball on few languages and choose that more liked. learning language with numbers and strings only is boring. also you can program tasks from https://www.codingame.com/training/easy with dozen languages in web browser before install to local machine. some of them contains graphics https://www.codingame.com/ide/puzzle/power-of-thor-episode-1 when u run tests. read data from stdin, print result to stdout, and use stderr for debugging with diagnostics messages.
Re: Return the complete number
On Wednesday, 24 July 2019 at 16:16:15 UTC, Greatsam4sure wrote: On Wednesday, 24 July 2019 at 15:57:06 UTC, a11e99z wrote: On Wednesday, 24 July 2019 at 15:56:13 UTC, a11e99z wrote: On Wednesday, 24 July 2019 at 15:45:08 UTC, Greatsam4sure The result is always to six significant figure. I want the whole number to be display see another answers at thread https://forum.dlang.org/post/qh9v10$19v1$1...@digitalmars.com https://forum.dlang.org/post/afzqnnorzwosimfqn...@forum.dlang.org
Re: Return the complete number
On Wednesday, 24 July 2019 at 15:45:08 UTC, Greatsam4sure wrote: int main(){ double mum = 0; Write("enter a number: ") readf(" %s\n",&num); Writeln(num); } How do I return the complete number the user enter since I don't since the user can enter numbers of various length with dmd approximating it. I will appreciate any help as drug said: writefln with formatting in case no need prints just string representation use s/format https://dlang.org/phobos/std_format.html#format auto str = num.format!"%.16s"; // using UFCS or auto str = "%.16s".format( num); // UFCS too for 2nd version of format or string str = format( "%.16s", num); simple help can be asked on IRC channel too irc://irc.freenode.net/d (HexChat, mIRC clients and others)
Re: Return the complete number
On Wednesday, 24 July 2019 at 15:56:13 UTC, a11e99z wrote: On Wednesday, 24 July 2019 at 15:45:08 UTC, Greatsam4sure wrote: int main(){ double mum = 0; Write("enter a number: ") readf(" %s\n",&num); Writeln(num); } How do I return the complete number the user enter since I don't since the user can enter numbers of various length with dmd approximating it. I will appreciate any help readf!" %s\n"( num ); or num.readf!" %s\n"; or num = readln.strip.to!double; oops! i misunderstood
Re: Return the complete number
On Wednesday, 24 July 2019 at 15:45:08 UTC, Greatsam4sure wrote: int main(){ double mum = 0; Write("enter a number: ") readf(" %s\n",&num); Writeln(num); } How do I return the complete number the user enter since I don't since the user can enter numbers of various length with dmd approximating it. I will appreciate any help readf!" %s\n"( num ); or num.readf!" %s\n"; or num = readln.strip.to!double;
Re: Memory allocation failed in CT
On Saturday, 13 July 2019 at 06:25:37 UTC, Andrey wrote: On Tuesday, 9 July 2019 at 19:04:53 UTC, Max Haughton wrote: Is this a 64 or 32 bit compiler? Also could you post the source code if possible? You could try "--DRT-gcopt=profile:1" druntime flag to see if the compiler is running out of memory for real Thanks for help. I solved my issue by rewritting code. can u describe how u rewrote the code? so it can be solution for all of us: when u generate long string in CT for mixins and u get an exception u can do next ...
Re: SendMessageTimeoutW requires casting string to uint?
On Tuesday, 9 July 2019 at 12:14:38 UTC, BoQsc wrote: On Tuesday, 9 July 2019 at 11:11:53 UTC, Dejan Lekic wrote: auto result = SendMessageTimeoutW( HWND_BROADCAST, WM_SETTINGCHANGE, 0, envi.toUTF16z, SMTO_ABORTIFHUNG, timeout, null ); C:\Users\User\Desktop>rdmd ref.d ref.d(19): Error: function `core.sys.windows.winuser.SendMessageTimeoutW(void*, uint, uint, int, uint, uint, uint*)` is not callable using argument types `(void*, int, int, const(wchar)*, int, uint, typeof(null))` ref.d(19):cannot pass argument `toUTF16z(cast(const(char)[])envi)` of type `const(wchar)*` to parameter `int` Failed: ["C:\\D\\dmd2\\windows\\bin\\dmd.exe", "-v", "-o-", "ref.d", "-I."] // add cast to LPARAM for SendMessageTimeoutW cast( LPARAM )envi.toUTF16z, // import lib too somewhere out of main() or in command line version(Windows) pragma(lib, "user32.lib");
Re: Why does `static foreach` lead to something calling `~=` internally?
On Sunday, 7 July 2019 at 17:07:59 UTC, a11e99z wrote: On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote: Why does this `static foreach` lead to hidden usage of operator `~=` calls in some cases? probably same oops! this one https://forum.dlang.org/post/eidpgqohllwmuumxw...@forum.dlang.org
Re: Why does `static foreach` lead to something calling `~=` internally?
On Sunday, 7 July 2019 at 16:51:57 UTC, 0xEAB wrote: Why does this `static foreach` lead to hidden usage of operator `~=` calls in some cases? probably same https://forum.dlang.org/post/qd9ee0$2eud$1...@digitalmars.com
Re: Is there something like a consuming take?
On Saturday, 6 July 2019 at 12:10:13 UTC, berni wrote: On Saturday, 6 July 2019 at 11:48:51 UTC, a11e99z wrote: Maybe I need to explain, what I dislike with this approach: take() calls popFront n times and drop() calls popFront another n times giving a total of 2n times (depending on the underlying range, this might cause lot's of calulcations be done twice. The first version with the foreach loop calls popFront only n times. auto take_consuming( R )( ref R r, int cnt ) { import std.range.primitives : hasSlicing; static if (hasSlicing!R) { // without allocations auto tmp = r[0..cnt]; r = r[cnt..$]; // or r.popFronN( cnt ); // O(1) return tmp; } else { // loop range once auto tmp = uninitializedArray!( ElementType!R[])( cnt); int k = 0; for (; !r.empty && kr.front; return tmp[ 0..k]; } }
Re: For loop with separator
On Saturday, 6 July 2019 at 11:48:42 UTC, berni wrote: On Thursday, 4 July 2019 at 17:00:33 UTC, Q. Schroll wrote: The prime example is printing the comma when printing a list: There is one between any two elements, but neither is one at front or behind the last one. If it is just for printing commas in between, you can use range.join(", ") https://dlang.org/phobos/std_array.html#.join .map!(e=>e.text).join( ", "); // map for non strings or .format!"%(%s, %)"; // for anything
Re: Is there something like a consuming take?
On Saturday, 6 July 2019 at 11:20:50 UTC, berni wrote: I want to copy the first n items of a range to an array, I came up with this now: data = r.take(n).array; This works partly, because the values of r are not consumed. So I have to call afterwards: r = r.drop(n); Now I wonder, if it is possible to do this with one single call, something like data = r.take_consuming(n).array; Does there something like this exist? sure auto take_consuming( R )( ref R r, int cnt ) { auto tmp = r.take( cnt ).array; r = r.drop( cnt ); return tmp; } don't thank
Re: Why are immutable array literals heap allocated?
On Thursday, 4 July 2019 at 10:56:50 UTC, Nick Treleaven wrote: immutable(int[]) f() @nogc { return [1,2]; } onlineapp.d(2): Error: array literal in `@nogc` function `onlineapp.f` may cause a GC allocation specify the size of the static array: immutable(int[ 2 /*HERE*/ ]) f() @nogc { return [1,2]; }
Re: assert in unittest has access to private member?
On Sunday, 30 June 2019 at 17:24:03 UTC, Robert M. Münch wrote: I have a case, with templates, where an assert in a unittest can access a private memember and I don't know how this can happen. Before trying to creat an equivalent case, I want to cross-check, if assert has special semantics in a unittest so that it can access private memembers? Private means that only members of the enclosing class can access the member, or vvv members and functions in the same module as the enclosing class. ^^^ did you take it into account?
Re: Finding the maxElement of Two-Dimensional Array
On Sunday, 30 June 2019 at 15:22:42 UTC, Samir wrote: How come this works: int[4][2] ta = [[2, 1, 4, 3], [3, 10, 2, 5]]; writeln(ta[1].maxElement); // get error on this line try to take slice from static arrays writeln(ta[1][].maxElement); or use dynamic arrays (slices) int[][] ta = [[2, 1, 4, 3], [3, 10, 2, 5]]; // or auto ta
Re: Reading formatted file
On Thursday, 27 June 2019 at 13:52:43 UTC, a11e99z wrote: On Thursday, 27 June 2019 at 13:31:23 UTC, Tabamon wrote: 1) try to google "dlang read text file", most probably 1,2,3 link will help to u. 2) https://dlang.org/library/std/file/read_text.html string content = readText( fileName ); 3) for matrix reading better to use byLine() https://dlang.org/library/std/stdio/file.by_line.html (see the samples below)
Re: Reading formatted file
On Thursday, 27 June 2019 at 13:31:23 UTC, Tabamon wrote: I am new at D, I'm making a sudoku solver in D, I wanted to add the option to read sudoku from a .txt file. 1) try to google "dlang read text file", most probably 1,2,3 link will help to u. 2) https://dlang.org/library/std/file/read_text.html string content = readText( fileName );