Re: Analyze debug condition in template
i want to eliminate "debug(func1)" and "debug(func2)" from code: ```d debug = func1;// enable logging for func1 //debug = func2; // disable logging for func2 void func1() { ... debug(func1) logf("var1=%d", var1); ... } void func2() { ... debug(func2) logf("var1=%d", var1); ... } ```
Analyze debug condition in template
Hello. Need advice: Is it possible analyze "debug" condition in template, obtained from instantiation place? Like we using __LINE__ ? For example, i have template for logging: ```d void logf(string func = __FUNCTION__, int line = __LINE__, A...)(string fmt, A args) { // here i want analyze, if debug == func // and writef conditionally writefln("%s:%d " ~ fmt, func, line, args); } ``` And i want switch on logging for one function module1.func(), then i declare in module1 ```d debug = func1; // enable logging for func1 void func1() { ... logf("var1=%d", var1); ... } ``` And i want to check in logf()() template: is debug condition equal function name, which instantiate logf() template. Just advise me direction or proper keyword ... Thanks.
Re: std.zip expand: memory allocation failed
On Monday, 25 October 2021 at 20:50:40 UTC, Steven Schveighoffer wrote: On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out my computer was literally running out of memory as the file was getting unzipped. For some reason to uncompress a 1-gig file with uncompressed size of 4-gig, Zip Archive of D-Lang tries to use more than 16 gig of RAM. I don't know why. Maybe I missed something. I use a Windows 10, DMD v2.091 with x86_mscoff. Wait, x86 is 32-bit. Max address space is 4GB. So maybe it was just trying to use 4GB and running out of memory? -Steve Good catch, but still, should it use so much memory?
Re: std.zip expand: memory allocation failed
On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out my computer was literally running out of memory as the file was getting unzipped. For some reason to uncompress a 1-gig file with uncompressed size of 4-gig, Zip Archive of D-Lang tries to use more than 16 gig of RAM. I don't know why. Maybe I missed something. I use a Windows 10, DMD v2.091 with x86_mscoff. Wait, x86 is 32-bit. Max address space is 4GB. So maybe it was just trying to use 4GB and running out of memory? -Steve
Re: Error: Could not open 'libcmt.lib'
On Monday, 25 October 2021 at 15:43:06 UTC, Willem wrote: I was able to resolve above issues by following the install guide by DrIggy @ https://www.youtube.com/watch?v=fuJBj_tgsR8 Thanks for posting it. Willem A friend of mine was with this issue. We just end up using ldc2 but would be nice to know the actual fix for dub with dmd
Re: std.zip expand: memory allocation failed
On Sunday, 24 October 2021 at 14:14:08 UTC, Imperatorn wrote: Create an issue and we can solve it Thanks. I opened an issue. https://issues.dlang.org/show_bug.cgi?id=22436
Re: Error: Could not open 'libcmt.lib'
I was able to resolve above issues by following the install guide by DrIggy @ https://www.youtube.com/watch?v=fuJBj_tgsR8 Thanks for posting it. Willem
Error: Could not open 'libcmt.lib'
Just starting out new with D. Up until now I have been using Python and a bit of OCaml. Error when linking: "lld-link: error: could not open 'libcmt.lib': no such file or directory" What I did: I installed the complete D setup in my Windows 10 PC -- including VS 2019. From the command line "C:\D\dmd2vars64.bat" I was able to creating a simple program with "dub init hello" When executing it with "dub run hello" I get following error: "lld-link: error: could not open 'libcmt.lib': no such file or directory" However -- running "dub run --arch=x86" did work dmd --version DMD64 D Compiler v2.098.0-dirty dub --version DUB version 1.27.0, built on Oct 10 2021 Searching the forum it appear to be related to MS runtimes... but I have not yet been able to resolve it. Any suggestions would be greatly appreciated. Many Thanks.
Re: TimeoutException for connecting to MySQL using a hunt-entity.
On Monday, 25 October 2021 at 07:45:26 UTC, Imperatorn wrote: On Friday, 22 October 2021 at 11:42:34 UTC, greenbyte wrote: Hi, all! I use the hunt-entity library to work with MySQL. I get the hunt.Exceptions.TimeoutException: "Timeout in 30 secs" when trying to connect. I configured MySQL and ran the code from the instructions https://github.com/huntlabs/hunt-entity MySQL: mysql Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL) DUB: version 1.25.0, built on Apr 23 2021 In dub.json enabled "hunt-entity": "~>2.7.3" And also of course triple check your credentials etc. Yes. When credentials don't match, I have AccessDenied exception.
Re: what's the most efficient way to implement std.container.binaryheap.back()?
On Monday, 25 October 2021 at 04:49:12 UTC, mw wrote: Hi, https://dlang.org/phobos/std_container_binaryheap.html The binary heap induces structure over the underlying store such that accessing the largest element (by using the front property) is a Ο(1) operation. I'm wondering what's the most efficient (in terms of both speed and memory usage) way to implement std.container.binaryheap.back()? i.e accessing the smallest element. Has anyone done this before? Thanks. I didn't look at the implementation, but the implementations I have looked at are backed by an array (a random access container would do). If so you need to find the min of elements from the largest "one less than a power of two" less than the size of the heap up to the size of heap. However, perhaps an alternative data struct would be better? See e.g. https://en.m.wikipedia.org/wiki/Min-max_heap On Monday, 25 October 2021 at 04:49:12 UTC, mw wrote:
Re: Why do we have Dmain?
On Monday, 25 October 2021 at 07:49:44 UTC, user1234 wrote: in addition to the other answers, there's also the parameters of main: Also, all programs running under the D runtime have special command line arguments(`--DRT` arguments). The Runtime needs to be able to parse those arguments at some point (among other initilisation), hence why the runtime handles the "true" main for us.
Re: Why do we have Dmain?
On Monday, 25 October 2021 at 07:49:44 UTC, user1234 wrote: so with the D main you're directly in the the D "domain". In theory from that point, you don't need to ever use `strlen` for example. Not just that, but you shouldn't use it at all, rather you can't use it! You might be able to call it, but it won't work as expected because strings are not zero-terminated in D, unless the string is a literal. strlen looks for \0, so using it for a string that isn't zero-terminated is asking for trouble.
Re: Why do we have Dmain?
On Friday, 22 October 2021 at 05:54:21 UTC, Kirill wrote: I am not a compiler expert, but I genuinely would like to know why we have Dmain. I've been looking at the generated assembly code recently and noticed the _Dmain function. I didn't notice it before. Then there is main, where Dmain is called. Why is that? in addition to the other answers, there's also the parameters of main: int argc, char** argv becomes string[] so with the D main you're directly in the the D "domain". In theory from that point, you don't need to ever use `strlen` for example.
Re: TimeoutException for connecting to MySQL using a hunt-entity.
On Friday, 22 October 2021 at 11:42:34 UTC, greenbyte wrote: Hi, all! I use the hunt-entity library to work with MySQL. I get the hunt.Exceptions.TimeoutException: "Timeout in 30 secs" when trying to connect. I configured MySQL and ran the code from the instructions https://github.com/huntlabs/hunt-entity MySQL: mysql Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL) DUB: version 1.25.0, built on Apr 23 2021 In dub.json enabled "hunt-entity": "~>2.7.3" And also of course triple check your credentials etc.
Re: TimeoutException for connecting to MySQL using a hunt-entity.
On Monday, 25 October 2021 at 07:15:42 UTC, bauss wrote: On Sunday, 24 October 2021 at 20:58:22 UTC, greenbyte wrote: On Friday, 22 October 2021 at 11:51:03 UTC, WebFreak001 wrote: On Friday, 22 October 2021 at 11:42:34 UTC, greenbyte wrote: Hi, all! I use the hunt-entity library to work with MySQL. I get the hunt.Exceptions.TimeoutException: "Timeout in 30 secs" when trying to connect. I configured MySQL and ran the code from the instructions https://github.com/huntlabs/hunt-entity MySQL: mysql Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL) DUB: version 1.25.0, built on Apr 23 2021 In dub.json enabled "hunt-entity": "~>2.7.3" From the error message you posted it seems like it's failing to connect. Did you check that the IP address and port you are connecting to are correct? In case of localhost, try 127.0.0.1 instead of "localhost" Yes, I did. Did you check your firewall configuration and that you're allowed to establish a connection to the port? Firewall disabled.
Re: TimeoutException for connecting to MySQL using a hunt-entity.
On Sunday, 24 October 2021 at 20:58:22 UTC, greenbyte wrote: On Friday, 22 October 2021 at 11:51:03 UTC, WebFreak001 wrote: On Friday, 22 October 2021 at 11:42:34 UTC, greenbyte wrote: Hi, all! I use the hunt-entity library to work with MySQL. I get the hunt.Exceptions.TimeoutException: "Timeout in 30 secs" when trying to connect. I configured MySQL and ran the code from the instructions https://github.com/huntlabs/hunt-entity MySQL: mysql Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL) DUB: version 1.25.0, built on Apr 23 2021 In dub.json enabled "hunt-entity": "~>2.7.3" From the error message you posted it seems like it's failing to connect. Did you check that the IP address and port you are connecting to are correct? In case of localhost, try 127.0.0.1 instead of "localhost" Yes, I did. Did you check your firewall configuration and that you're allowed to establish a connection to the port?