logoalt Hacker News

Joker_vD • today at 4:51 AM • 0 replies • view on HN

I am fairly certain that even today, C89 compilers (or compilers for later C standards in the C89 mode, if they have it) can still compile the C89 programs just fine.

The desire to compile C89 programs with e.g. a C26 compiler (that is, a compiler for a similar, but different language), and yet still get the program with exactly the same observable behaviour, always struck me as strange. If you want to keep using your old compiler, you can use it. If you want to port your program to a newer version — well, you'll have to port it. They way to actually make this porting easier would be to have required diagnostics in the compilers but that seems to be counter-cultural to the C community in large.

Of course, the proper way to ensure backward compatibility would be to have every translation unit start with something like "#pragma std(c99)" and then mandate that the semantics of the corresponding language standard shall apply during translation of this translation unit, and that the conforming implementation must support all the previous language standards (in conformant way)... but again, that'd never fly with the C community, neither with the implementers nor the programmers — instead we have a vague definition of what "C code" is (and what is its semantics), which is time-dependent, but efforts are made to ensure that things that used to be C code, and their semantics, still count as C code and their semantics don't noticeably change over time (well, maybe).