Using array slices with C-style fread() from file
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 21 12:11:44 PDT 2017
On 06/21/2017 12:06 PM, uncorroded wrote:
> Is
> there any way of making the function with @safe as well? I get the
> errors "cannot call @system function
'core.stdc.stdio.fread,fopen,fclose'.
@trusted is exactly for that. It can be called from @safe code:
@trusted @nogc ubyte[n] rand_bytes(uint n)() {
// ...
}
@safe auto foo() {
return rand_bytes!3();
}
Ali
More information about the Digitalmars-d-learn
mailing list