On Wednesday, 27 December 2023 at 20:20:23 UTC, tososdk wrote:
I was recreating some code from C++ to D:
[...]
But since I am somewhat new to these topics and even more so to
Dlang, I don't understand very well. The problem occurs in the
creation of the .wav, regarding rawWrite, I'm not really sure
what to do in that specific part. Maybe I'm ignorant, but I'm
not very good at these topics, plus it's for experimentation.
Here's the error message I got when I tried to compile your code:
```
Error: template `std.stdio.File.rawWrite` is not callable using
argument types `!()(WavHeader)`
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d(1273):
Candidate is: `rawWrite(T)(in T[] buffer)`
```
What this message is saying is that you tried to pass a
`WavHeader` to `rawWrite`, but `rawWrite` expects a slice (`T[]`,
where `T` can be any type) as an argument.
The easiest way to fix this is to use [pointer slicing][1] to
create a temporary slice that points to `wavh`:
```d
file.rawWrite((&wahv)[0 .. 1]);
```
[1]: https://dlang.org/spec/expression.html#slice_expressions