Re: Request help on allocator.

2023-12-02 Thread IGotD- via Digitalmars-d-learn
On Saturday, 2 December 2023 at 19:13:18 UTC, Vino B wrote: Hi All, Request your help in understanding the below program, with the below program I can allocate 8589934592(8GB) it prints the length 8589934592(8GB) where as my laptop has only 4 GB so the confusion is that how can this

Re: Request help on allocator.

2023-12-02 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 2 December 2023 at 19:13:18 UTC, Vino B wrote: Hi All, Request your help in understanding the below program, with the below program I can allocate 8589934592(8GB) it prints the length 8589934592(8GB) where as my laptop has only 4 GB so the confusion is that how can this

Request help on allocator.

2023-12-02 Thread Vino B via Digitalmars-d-learn
Hi All, Request your help in understanding the below program, with the below program I can allocate 8589934592(8GB) it prints the length 8589934592(8GB) where as my laptop has only 4 GB so the confusion is that how can this program allocate 8GB RAM when I have only 4GB of RAM installed

Re: How to hash SHA256 from string?

2023-12-02 Thread Sergey via Digitalmars-d-learn
On Saturday, 2 December 2023 at 15:30:39 UTC, zoujiaqing wrote: SHA Sorry for OT, but don’t know different place to reach you out. What is the status of Archttp? Is it discontinued/abandoned?

Re: How to hash SHA256 from string?

2023-12-02 Thread An Pham via Digitalmars-d-learn
On Saturday, 2 December 2023 at 15:30:39 UTC, zoujiaqing wrote: ```D string appKey = "1"; ubyte[1024] data = cast(ubyte[])(appKey.dup[0..$]); sha256.put(data); Your data has garbage at the end; try

Re: How to hash SHA256 from string?

2023-12-02 Thread user1234 via Digitalmars-d-learn
On Saturday, 2 December 2023 at 16:17:08 UTC, user1234 wrote: On Saturday, 2 December 2023 at 15:30:39 UTC, zoujiaqing wrote: [...] sign is binary, you have to use the toHexString utility : ```d import std.stdio; import std.digest.sha; void main() { SHA256 sha256; sha256.start();

Re: Inversion of conditional compilation statements

2023-12-02 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 2 December 2023 at 15:48:02 UTC, Nick Treleaven wrote: On Saturday, 2 December 2023 at 15:03:25 UTC, ryuukk_ wrote: I wish we could use ``version`` as expression, to void the repetition: ```D import std.stdio; enum HasTest = version (Test) ? true : false; Tomek Sowiński wrote

Re: How to hash SHA256 from string?

2023-12-02 Thread user1234 via Digitalmars-d-learn
On Saturday, 2 December 2023 at 15:30:39 UTC, zoujiaqing wrote: ```D import std.stdio; import std.digest.sha; void main() { SHA256 sha256; sha256.start(); string appKey = "1"; ubyte[1024] data =

Re: Inversion of conditional compilation statements

2023-12-02 Thread Nick Treleaven via Digitalmars-d-learn
On Saturday, 2 December 2023 at 15:03:25 UTC, ryuukk_ wrote: I wish we could use ``version`` as expression, to void the repetition: ```D import std.stdio; enum HasTest = version (Test) ? true : false; Tomek Sowiński wrote this template: ```d enum bool isVersion(string ver) = !is(typeof({

How to hash SHA256 from string?

2023-12-02 Thread zoujiaqing via Digitalmars-d-learn
```D import std.stdio; import std.digest.sha; void main() { SHA256 sha256; sha256.start(); string appKey = "1"; ubyte[1024] data = cast(ubyte[])(appKey.dup[0..$]); sha256.put(data); ubyte[32] sign = sha256.finish();

Re: Inversion of conditional compilation statements

2023-12-02 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 2 December 2023 at 13:16:26 UTC, Johannes Miesenhardt wrote: Hello, I am trying to learn D and I have stumbled upon an issue Consider this code: ```d import std.stdio; //version = Test; int main() { version (Test) { writeln("Hello, world!"); }

Re: Advent of Code 2023

2023-12-02 Thread Sergey via Digitalmars-d-learn
On Saturday, 2 December 2023 at 13:33:33 UTC, Johannes Miesenhardt wrote: Day 1 solution here, since I swap them out based on a runtime argument. In the Discord server we also have a topic about AoC2023. So feel free to join it as well. Some other solutions that could be worth to check:

Re: Inversion of conditional compilation statements

2023-12-02 Thread user1234 via Digitalmars-d-learn
On Saturday, 2 December 2023 at 13:16:26 UTC, Johannes Miesenhardt wrote: Hello, [...] I see the way why it doesn't work, but I think it should. Considering that `version (Test) {} else {` works without any issue but looks very ugly. Can somebody explain if this is an intended decision or

Re: Advent of Code 2023

2023-12-02 Thread Johannes Miesenhardt via Digitalmars-d-learn
On Friday, 1 December 2023 at 01:01:31 UTC, Siarhei Siamashka wrote: Advent of Code 2023 starts in a few hours from now. I suggest to discuss D language solutions here. But to avoid spoilers, it's best to do this with a 24h delay after each puzzle is published. Day 1 solution ```d version =

Inversion of conditional compilation statements

2023-12-02 Thread Johannes Miesenhardt via Digitalmars-d-learn
Hello, I am trying to learn D and I have stumbled upon an issue Consider this code: ```d import std.stdio; //version = Test; int main() { version (Test) { writeln("Hello, world!"); } return 0; } ``` This compiles, however what if we want to turn the

Re: vibe-d REST API: POSTing a struct

2023-12-02 Thread bomat via Digitalmars-d-learn
On Friday, 1 December 2023 at 19:18:19 UTC, bomat wrote: So my question is, is it possible to have vibe-d parse the request body into a struct "implicitly"? I'm gonna answer my own question here, it's `@bodyParam`. https://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/40001/

Re: ImportC: Windows.h

2023-12-02 Thread name via Digitalmars-d-learn
On Saturday, 2 December 2023 at 08:36:01 UTC, Stefan Koch wrote: On Saturday, 2 December 2023 at 05:16:43 UTC, name wrote: Minimum thing to reproduce bug: [...] It doesn't show up since it's defined as an Identifier Expression which cannot be resolved. But why can't it be resolved?

Re: ImportC: Windows.h

2023-12-02 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 2 December 2023 at 05:16:43 UTC, name wrote: Minimum thing to reproduce bug: main.d: ```d import test; void main() { auto a = FILE_MAP_READ; } ``` test.c ```c #define SECTION_MAP_READ 0x0004 #define FILE_MAP_READ SECTION_MAP_READ ``` build with