Discussion Thread: DIP 1028--Make @safe the Default--Final Review

Atila Neves atila.neves at gmail.com
Thu Mar 26 16:02:22 UTC 2020


On Thursday, 26 March 2020 at 11:40:41 UTC, IGotD- wrote:
>
> FFI functions like extern(C) must be @system as the compiler 
> cannot check this. Should extern(C) automatically mean @system? 
> Well I think so because that's the only feasible possibility.

The problem I see is this:

extern(C) int add1(int i, int j) @safe {
     return i + j + 1;
}

extern(C) doesn't necessarily mean the code is written in C and 
can't be verified by the compiler. It might just be written in D 
(or C++, or Rust, or...). I do however understand why one would 
want to say that an external C library has no @safe interface. 
But that can be done by applying @system manually. I'm not sure 
what the best solution is.



More information about the Digitalmars-d mailing list