Type safety could prevent nuclear war
Ola Fosheim Grøstad via Digitalmars-d
digitalmars-d at puremagic.com
Thu Feb 4 15:25:58 PST 2016
On Thursday, 4 February 2016 at 23:21:54 UTC, tsbockman wrote:
> Definitely. What puzzles me about the winning entry, though, is
> that the compiler and/or linker should be able to trivially
> detect the type mismatch *after* the preprocessor pass(es) are
> already done.
Linkers don't know anything about types. A type is a language
feature.
> It should just see that the post-preprocessor signatures of
> `spectral_contrast()` in match.c and spectral_contrast.c are in
> conflict, and either issue a warning, or refuse to link them at
> all.
Has nothing to do with the preprocessor.
He defined float_t to be an alias for double in one compilation
unit, and float_t to be an alias for float in another compilation
unit.
In C, compilation units are completely independent, and can in
fact come from different compilers and different languages. C is
very much a system level programming language.
More information about the Digitalmars-d
mailing list