Re: D: Convert/parse uint integer to string. (@nogc)

2023-11-30 Thread Siarhei Siamashka via Digitalmars-d-learn
On Friday, 24 November 2023 at 09:35:00 UTC, BoQsc wrote: I tried to look into https://dlang.org/phobos/std_conv.html Most of the functions inside `std.conv` seem to be dependant on [Garbage Collection](https://dlang.org/spec/garbage.html). And I couldn't find a straightforward way to produce

Re: D: Convert/parse uint integer to string. (@nogc)

2023-11-30 Thread kdevel via Digitalmars-d-learn
On Tuesday, 28 November 2023 at 09:43:47 UTC, Dom DiSc wrote: On Tuesday, 28 November 2023 at 08:51:21 UTC, Mark Davies wrote: On Friday, 24 November 2023 at 09:35:00 UTC, BoQsc wrote: ``` import std.stdio; char[10] longToString(long n) @nogc ``` For a 'long' 10 characters is likely to be not

Re: D: Convert/parse uint integer to string. (@nogc)

2023-11-30 Thread kdevel via Digitalmars-d-learn
On Friday, 24 November 2023 at 13:05:30 UTC, Ferhat Kurtulmuş wrote: [...] ``` import core.stdc.stdio : sprintf; import core.stdc.math : log10; import std.exception : assumeUnique; import std.stdio : writeln; size_t nod(int num){ return cast(size_t)((num==0)?1:log10(num)+1); }

Re: ImportC: Windows.h

2023-11-30 Thread name via Digitalmars-d-learn
Weird... building with ```dmd -m64 -i main.d``` works fine. Then, I tried calling [CreateFileW](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew), passing ```GENERIC_READ``` for ```[in] dwDesiredAccess```; I get this: ```main.d(7): Error: undefined identifier

Re: struct initializer

2023-11-30 Thread zjh via Digitalmars-d-learn
On Wednesday, 29 November 2023 at 16:38:36 UTC, Dom DiSc wrote: ```d struct S { int a; int b; } S2 fun3() { return S2( 5, 2 ); } ``` Here,`S2( 5, 2 );` violeit `DRY` principle.

Re: struct initializer

2023-11-30 Thread Dennis via Digitalmars-d-learn
On Thursday, 30 November 2023 at 07:21:29 UTC, Dom DiSc wrote: So, why supporting the (somewhat strange looking) version with curly backets at all? It only works in one special place, so is simply overhead to remember. Again a superfluous way to do the same - but only under specific circumstanc

Re: ImportC: Windows.h

2023-11-30 Thread name via Digitalmars-d-learn
On Thursday, 30 November 2023 at 08:54:40 UTC, Kagamin wrote: You can declare them ``` extern(C) void _InterlockedExchangeAdd(){ assert(false); } ``` That works, thanks.

Re: ImportC: Windows.h

2023-11-30 Thread Kagamin via Digitalmars-d-learn
You can declare them ``` extern(C) void _InterlockedExchangeAdd(){ assert(false); } ```