On Wednesday, 21 June 2017 at 19:11:44 UTC, Ali Çehreli wrote:
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
Thanks! So @trusted is me guaranteeing to the compiler that this
function is safe? Is there any way of auditing this code through
valgrind, etc. Also, thanks a lot for your book on D. It has been
an invaluable resource in getting me started.