Comment #0 by snarwin+bugzilla — 2022-10-17T03:27:58Z
The following program compiles on Linux, but not on Windows:
---
import std.stdio;
void main() @safe
{
}
private ubyte readByte(File file) @safe
in(file.isOpen)
{
ubyte[1] buffer;
return file.rawRead(buffer)[0];
}
---
The error message is:
--
Performing "debug" build using C:\D\dmd2\windows\bin\dmd.exe for x86_64.
safetest ~master: building configuration "application"...
Performing "debug" build using C:\D\dmd2\windows\bin\dmd.exe for x86_64.
safetest ~master: building configuration "application"...
source\app.d(12,24): Error: `@safe` function `app.readByte` cannot call `@system` function `std.stdio.File.rawRead!ubyte.rawRead`
C:\D\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(1138,9): `std.stdio.File.rawRead!ubyte.rawRead` is declared here
C:\D\dmd2\windows\bin\dmd.exe failed with exit code 1.
---
The cause is likely several calls to extern(C) functions in a version (Windows) block:
https://github.com/dlang/phobos/blob/v2.100.2/std/stdio.d#L1145-L1159
Comment #1 by robert.schadek — 2024-12-01T16:40:37Z