Type safety could prevent nuclear war

tsbockman via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 4 16:03:20 PST 2016


On Thursday, 4 February 2016 at 23:51:57 UTC, anonymous wrote:
> We do have a lot of bindings to C libraries, though. When 
> there's a wrong alias in one of them, you have the same 
> scenario.
>
> On 05.02.2016 00:47, tsbockman wrote:
>> Even so, I think that qualifies as a compiler bug or a hole in 
>> the D spec.
>
> Can anything be done about it? The compiler simply has no way 
> to verify declarations, has it?

The compiler cannot (in the general case) verify that `extern(C)` 
declarations are *correct*. What it could do, though, is verify 
that they are *consistent*.

If the same `extern(C)` symbol is declared multiple places in the 
D source code for a program, the compiler should issue at least a 
warning if the D signatures don't agree with each other.


More information about the Digitalmars-d mailing list