Re: Some user-made C functions and their D equivalents

2022-07-27 Thread pascal111 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 00:36:54 UTC, ryuukk_ wrote: I don't remember the exact syntax for GDC, but it should be pretty similar to DMD You need to pass the module to the compiler gdc main.d dcollect.d I'm using CODE::BLOCKS IDE. How can I do it through it?

Re: Some user-made C functions and their D equivalents

2022-07-27 Thread ryuukk_ via Digitalmars-d-learn
I don't remember the exact syntax for GDC, but it should be pretty similar to DMD You need to pass the module to the compiler gdc main.d dcollect.d

Re: Some user-made C functions and their D equivalents

2022-07-27 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 27 July 2022 at 19:07:26 UTC, ryuukk_ wrote: On Wednesday, 27 July 2022 at 18:19:34 UTC, pascal111 wrote: I made a library of some useful functions while I was studying C, and I'm curious to know if D has equivalents or some ones for some of my functions, or I have to retype 'em

Re: Particular exceptions names

2022-07-27 Thread kdevel via Digitalmars-d-learn
On Wednesday, 27 July 2022 at 09:35:12 UTC, Ali Çehreli wrote: The following program show an example as well as 'enforce', which I prefer over explicit if+throw+else: Me too. enforce!MissingArguments(args.length == 42, format!"Too few arguments:

Re: Particular exceptions names

2022-07-27 Thread kdevel via Digitalmars-d-learn
On Tuesday, 26 July 2022 at 23:43:59 UTC, pascal111 wrote: In next example code, it used user-made exception, [...] try { if( b == 0 ) { throw new Exception("Cannot divide by zero!"); } else { result = format("%s",a/b); }

Re: Some user-made C functions and their D equivalents

2022-07-27 Thread ryuukk_ via Digitalmars-d-learn
On Wednesday, 27 July 2022 at 18:19:34 UTC, pascal111 wrote: I made a library of some useful functions while I was studying C, and I'm curious to know if D has equivalents or some ones for some of my functions, or I have to retype 'em again in D. The library link:

Re: Exclamation symbol "!" within functions syntax

2022-07-27 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 27 July 2022 at 11:09:19 UTC, Ali Çehreli wrote: On 7/27/22 04:00, pascal111 wrote: I noticed more than once that the exclamation "!" is used within functions typing, and it seems like an operator with new use, for example "to!int()", ".tee!(l => sum += l.length)",

Some user-made C functions and their D equivalents

2022-07-27 Thread pascal111 via Digitalmars-d-learn
I made a library of some useful functions while I was studying C, and I'm curious to know if D has equivalents or some ones for some of my functions, or I have to retype 'em again in D. The library link: https://github.com/pascal111-fra/turbo-c-programs/blob/main/COLLECT2.H

Re: BetterC Name Mangling Linker Errors

2022-07-27 Thread MyNameHere via Digitalmars-d-learn
Thank you, that seems to have been the source of the error.

Re: BetterC Name Mangling Linker Errors

2022-07-27 Thread Dennis via Digitalmars-d-learn
On Wednesday, 27 July 2022 at 12:26:59 UTC, MyNameHere wrote: ```d void Main(void* Instance) { WNDCLASSEXA WindowClass; ``` This is equivalent to `WNDCLASSEXA WindowClass = WNDCLASSEXA.init;` If the struct's fields all initialize to 0, the compiler would simply set the variable's bytes

BetterC Name Mangling Linker Errors

2022-07-27 Thread MyNameHere via Digitalmars-d-learn
I have included the source to a simple 64-bit Windows program. It compiles and runs fine with ```dmd -m64 -L="/Subsystem:Windows" -L="/Entry:Main" Main.d```. But compiling with ```-betterC``` using the following throws up a linker error, ```dmd -m64 -betterC -L="/Subsystem:Windows"

Re: Exclamation symbol "!" within functions syntax

2022-07-27 Thread Ali Çehreli via Digitalmars-d-learn
On 7/27/22 04:00, pascal111 wrote: I noticed more than once that the exclamation "!" is used within functions typing, and it seems like an operator with new use, for example "to!int()", ".tee!(l => sum += l.length)", "enforce!MissingArguments...", so what dose it means? The binary !

Exclamation symbol "!" within functions syntax

2022-07-27 Thread pascal111 via Digitalmars-d-learn
I noticed more than once that the exclamation "!" is used within functions typing, and it seems like an operator with new use, for example "to!int()", ".tee!(l => sum += l.length)", "enforce!MissingArguments...", so what dose it means?

Re: Particular exceptions names

2022-07-27 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 27 July 2022 at 09:35:12 UTC, Ali Çehreli wrote: On 7/26/22 16:43, pascal111 wrote: > [...] I am not sure I understand you correctly because the program you show throws Exception, which is not user-made at all. [...] It seems an advanced topic. It'll take some more studying

Re: Particular exceptions names

2022-07-27 Thread Ali Çehreli via Digitalmars-d-learn
On 7/26/22 16:43, pascal111 wrote: > In next example code, it used user-made exception, I am not sure I understand you correctly because the program you show throws Exception, which is not user-made at all. If you want to throw a particual exception that you define, you need to inherit that

Re: Particular exceptions names

2022-07-27 Thread frame via Digitalmars-d-learn
On Tuesday, 26 July 2022 at 23:43:59 UTC, pascal111 wrote: In next example code, it used user-made exception, but what if I'm looking for a particular exception? from where can I get particular exception to arise it? There is no mechanism to find a particular exceptions in D. You have simple