Re: Linkage question

2022-01-24 Thread duser via Digitalmars-d-learn
On Monday, 24 January 2022 at 19:41:30 UTC, frame wrote: On Monday, 24 January 2022 at 18:30:02 UTC, Stanislav Blinov wrote: The difference is in how arguments are being passed, which you seem to have discovered already :) Would like to know where the linkage format is defined, thx. It sh

Re: unordered output of an associated array of associated arrays

2022-01-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 25, 2022 at 02:46:43AM +, forkit via Digitalmars-d-learn wrote: > On Tuesday, 25 January 2022 at 02:12:50 UTC, H. S. Teoh wrote: > > > > That's the *easy* way out?? Try this instead: > > > > aaTable.keys.sort.each!((k) { > > aaTable[k].keys.sort.each!((kk) { > >

Re: What is safe to do in an extern (C) function and how can I test this?

2022-01-24 Thread Jaime via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 01:41:03 UTC, Steven Schveighoffer wrote: On 1/24/22 8:31 PM, Jaime wrote: Can I, for instance, safely call Fiber.yield in a C callback that I know will be run in a Fiber? I would *imagine* it's fine, all the fiber context switch is doing (WRT the stack) is swap

Re: unordered output of an associated array of associated arrays

2022-01-24 Thread forkit via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 02:12:50 UTC, H. S. Teoh wrote: That's the *easy* way out?? Try this instead: aaTable.keys.sort.each!((k) { aaTable[k].keys.sort.each!((kk) { writefln("%s:%s:%s", k, kk, aaTable[k][kk]); });

Re: unordered output of an associated array of associated arrays

2022-01-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 25, 2022 at 02:04:26AM +, forkit via Digitalmars-d-learn wrote: [...] > // -- > module test; > > import std; > > void main() > { > auto aaTable = > ([ >"typeB" : [ 10002 : [1, 1, 0, 0, 0, 0, 0, 0], >10001 : [1, 0, 0, 0, 0, 0, 0, 0] >

Re: unordered output of an associated array of associated arrays

2022-01-24 Thread forkit via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 00:43:07 UTC, forkit wrote: oh. thanks :-) I will get that integrated into my example code, and will post again, once it's working (so others can learn too) ok.. so I took the easy way out ;-) output is now ordered: typeA:10003:[1, 1, 1, 0, 0, 0, 0, 0] t

Re: What is safe to do in an extern (C) function and how can I test this?

2022-01-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 25, 2022 at 01:31:29AM +, Jaime via Digitalmars-d-learn wrote: > **The lede**: > > Can I, for instance, safely call Fiber.yield in a C callback that I > know will be run in a Fiber? > > The stack will look like: > Thread > |- Fiber in D runtime > | |- Call into a C API (stays on s

Re: What is safe to do in an extern (C) function and how can I test this?

2022-01-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/24/22 8:31 PM, Jaime wrote: **The lede**: Can I, for instance, safely call Fiber.yield in a C callback that I know will be run in a Fiber? The stack will look like: Thread |- Fiber in D runtime | |- Call into a C API (stays on same thread) | | |- Extern (C) callback (stays on same thread

What is safe to do in an extern (C) function and how can I test this?

2022-01-24 Thread Jaime via Digitalmars-d-learn
**The lede**: Can I, for instance, safely call Fiber.yield in a C callback that I know will be run in a Fiber? The stack will look like: Thread |- Fiber in D runtime | |- Call into a C API (stays on same thread) | | |- Extern (C) callback (stays on same thread) | | | |- Fiber.yield <-- Is this

Re: unordered output of an associated array of associated arrays

2022-01-24 Thread forkit via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 00:39:05 UTC, H. S. Teoh wrote: AA's are unordered containers. Do not rely on entries to appear in any specific order when you traverse an AA; it is implementation-dependent and may differ from OS to OS / platform to platform / sequence of operations performed

Re: unordered output of an associated array of associated arrays

2022-01-24 Thread forkit via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 00:23:40 UTC, forkit wrote: another example: output is: typeA: 10001:[0, 0, 1, 1, 1, 1, 1, 1] 10002:[0, 0, 0, 1, 1, 1, 1, 1] typeB: 10005:[0, 0, 0, 0, 0, 0, 1, 1] 10003:[0, 0, 0, 0, 1, 1, 1, 1] 10004:[0,

Re: unordered output of an associated array of associated arrays

2022-01-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 25, 2022 at 12:23:40AM +, forkit via Digitalmars-d-learn wrote: > so I'm trying to understand why the output of the code below, is in > reverse order of the declaration (and how to fix it so that it outputs > in an ordered way) AA's are unordered containers. Do not rely on entries

unordered output of an associated array of associated arrays

2022-01-24 Thread forkit via Digitalmars-d-learn
so I'm trying to understand why the output of the code below, is in reverse order of the declaration (and how to fix it so that it outputs in an ordered way) i.e. output is: typeA: A2:A2value A1:A1value typeB: B3:B3value B2:B2value B1:B1value // -- modu

Re: How to do same as 'nmap' command from within a D program?

2022-01-24 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 22 January 2022 at 20:55:38 UTC, Daren Scot Wilson wrote: I'm writing a command line program to control certain hardware devices. I can hardcode or have in a config file the IP addresses for the devices, if I know that info. If I don't? Depending on the hardware, you might be able

Re: How to do same as 'nmap' command from within a D program?

2022-01-24 Thread Daren Scot Wilson via Digitalmars-d-learn
On Sunday, 23 January 2022 at 06:30:11 UTC, frame wrote: On Saturday, 22 January 2022 at 20:55:38 UTC, Daren Scot Wilson wrote: I don't see any D std.* libraries that do this. Are there a Dub packages I should look at? If you really want to this in D without any external app or OS API you c

Re: Linkage question

2022-01-24 Thread Paul Backus via Digitalmars-d-learn
On Monday, 24 January 2022 at 19:41:30 UTC, frame wrote: It claims that the D calling convention matches C. But it seems that the arguments are pushed in order whereas C does it in reverse order and the -218697648 value is indeed my 3rd string pointer. Windows has two calling conventions for

Re: Linkage question

2022-01-24 Thread frame via Digitalmars-d-learn
On Monday, 24 January 2022 at 18:30:02 UTC, Stanislav Blinov wrote: The difference is in how arguments are being passed, which you seem to have discovered already :) Would like to know where the linkage format is defined, thx. It should be here: https://dlang.org/spec/abi.html although II

Re: Linkage question

2022-01-24 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 24 January 2022 at 17:23:01 UTC, frame wrote: I understand that the linkage must match but besides the name mangling, what's happen here? What is the difference if I remove the `extern (C)` part from the T alias? The difference is in how arguments are being passed, which you seem

Linkage question

2022-01-24 Thread frame via Digitalmars-d-learn
If I declare a function as extern(C) inside a DLL, I have also to cast the function pointer as extern(C) or it fails calling, eg. ```d // --- my.dll export extern (C) void log(int mode, string a, string b, string c) { /* stuff */ } // --- main.d alias T = extern (C) void function(int, strin

Re: dustmite and Windows file access errors

2022-01-24 Thread Vladimir Panteleev via Digitalmars-d-learn
On Monday, 24 January 2022 at 17:17:28 UTC, Anonymouse wrote: Indexing is off for the parent directory. What else can I do? Disable anti-virus. If that doesn't help, you could try using Sysinternals Process Monitor to check what is accessing the file.

dustmite and Windows file access errors

2022-01-24 Thread Anonymouse via Digitalmars-d-learn
This is maybe more a Windows (11) question than it is a dustmite one. Semi-OT. I'm trying to reduce https://forum.dlang.org/thread/muehtdyjabmjxosmj...@forum.dlang.org, and it's Windows so I don't know what I'm doing. After multiple attempts at piecing together a batch tester script that both c