Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-10 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 8 September 2023 at 13:34:42 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
In case you didn't know, all you need to get unittests working 
in -betterC is:


```d
foreach (module_; allModules) {
foreach (unitTest; __traits(getUnitTests, 
module_)) {
unitTest();
}
}
```

You'd need to provide allModules somehow, like dub does.

https://github.com/dlang/dub/blob/2ea883833adf085095b07a7dba8250fb3db79a71/source/dub/project.d#L1937


TIL, thanks for sharing, this will be very useful!


Dlang Forum: How to Subscribe to the "Replies to your posts"

2023-09-10 Thread BoQsc via Digitalmars-d-learn
Some people might not know that it is possible to subscribe and 
get notifications about replies to your forum posts via email.


1. Open main forum page and click **"new replies"** link

![img1](https://i.imgur.com/HwhDCKO.png)

---
2. Scroll down to the bottom of the page

![img2](https://i.imgur.com/MPxWxsB.png)

---

3. At the bottom of the page click the button **"Edit 
subscription"**


![img3](https://i.imgur.com/IbvBMZJ.png)

---

4. Complete the form that includes providing your email and click 
**"save"** button.
5. Next time someone will reply to your post, a notification to 
your email will be sent.


![img4](https://i.imgur.com/dxj6w2l.png)



Json Help

2023-09-10 Thread Vino via Digitalmars-d-learn

Hi All,

  Request your help on the below code,I am trying to convert the 
below string to json and it always throws the error, if the below 
can be accomplished with any other json package even that is 
fine, I tired only the std.json package.


Test Program: Works

import std.json;
import std.stdio: writeln;

void main () {

auto sadrsJson = parseJSON(`{ "TestHost": { "Building1": { 
"RackNo": 123}}}`);

writeln(sadrsJson);

}
```
Program: Does not Work
```
import std.json;
import std.stdio;
import std.container;
import std.socket: Socket;
import std.stdio: writeln;

void main () {

string host = Socket.hostName;
string registry = "Test"

Array!string output;
Array!string errors;

output.insertBack("TESTOUTPUT");
errors.insertBack("TESTERRORS");

auto sadrsJson = parseJSON({ host: { registry: { "OUTPUT": 
output[], "ERROR": errors[]}}});

writeln(sadrsJson);

}

From,
Vino.B


Re: pipeProcess output to hash string

2023-09-10 Thread Vino via Digitalmars-d-learn

On Saturday, 9 September 2023 at 16:49:30 UTC, user1234 wrote:

On Saturday, 9 September 2023 at 15:44:44 UTC, Vino wrote:

[...]


With a slightly modified command line that works on linux here :

```d
import std.process, std.stdio;

auto test(in Redirect redirect=Redirect.stdout | 
Redirect.stderr) {

import std.digest.crc;
import std.stdio: writeln;

 auto result = std.process.pipeProcess(["whoami"], 
redirect);

 auto content = result.stdout.readln;
 auto hash = crc32Of(content);
 return hash;
}
void main() {
  writeln(test);
}
```

not sure why you append "/?" to the program name.


Thank you, got it working.

From,
Vino