Safer binary reading (or writing) code
Joel
joelcnz at gmail.com
Tue Dec 12 09:43:39 UTC 2023
I've got this mixin thing, I think it's less typo-prone. I
haven't been able to make it show the variable's name, though.
Also, it should be optional whether it prints anything, (it's not
hard for me to do that though).
```d
// mixin(jread("width")); -> fread(&width, 1, width.sizeof,
bfile);
auto jread(string var) => `fread(&`~var~`, 1, `~var~`.sizeof,
bfile); writeln("read var=", `~var~`);`;
```
More information about the Digitalmars-d-learn
mailing list