3 ms·
> As this IOCCC entry shows, every single C++ revision has been a breaking change to the previous revision This post never mentions C++'s backwards compatibili
by vmarsy 10y ago
> As this IOCCC entry shows, every single C++ revision has been a breaking change to the previous revision
This post never mentions C++'s backwards compatibility. It points out these 3 examples:
// comments
C90 does not have // comments, so constructs of the form
...
i.e. more recent version of C and C++ is a super set of C90 here, but writing valid C90 (without using // comments), would compile file in C90 and above.
Wide string literals
C11 and C++11 have wide string literals where for example U"hello!"
Same reasoning for these, you would never use U"hello!" in pre C11/C++11.
The 3rd example is a fundamental difference between C and C++:
Character constants, such as 'a', have type int in C while C++ use the type char. This means that sizeof('a') evaluates to a different value for C and C++.
This is not about backward compatibility, backward compatibility means : your code written in C++98, still works if compiled in C++11, it does not say : "write code using newer C++98/11/.../ and try to compile it in a previous version (or a different language) and see what happens."
To an extreme it's like saying:
template<class A>
struct foo {
// some methods with use of lambda, variadic templates, ...
};
"Hey look, the above example doesn't work with C++98, C++ backward compatibility is a myth!"
- chx 10y agoYou contradict yourself: > backward compatibility means your code written in C++98, still works if compiled in C++11 > writing valid C90 (without using // comments), would compile file in C90 and above. Aye. There's the rub: backwards compatibility is broken by introducing // as int i = 2 //* */2 which is perfectly valid code in C90 evaluates to 1 while 2 in later version. When releasing later versions you are always breaking someones insane code. It's a matter of compromises between breaking 0.00000000001% of the codebase and progress. The number of zeroes in that percentage is of course debatable, see http://www.cl.cam.ac.uk/~pes20/cerberus/notes50-survey-discussion.html http://www.cl.cam.ac.uk/~pes20/cerberus/notes50-survey-discu... where a number of "Do you know of real code that relies on it?" are answered by ~20% of yes and ~20% of no, that would be crazy. So it is entirely possible the standards committee believes a construct is not used, that'd be crazy but it actually is used.
- ben0x539 10y agono version of C++ ever added new comment syntax that a previous version of C++ didnt have, tho
- Someone 10y agoNitpick: as far as I can tell that's _almost_ correct. http://www.softwarepreservation.org/projects/c_plus_plus/index.html#release_e http://www.softwarepreservation.org/projects/c_plus_plus/ind... leads me to http://www.softwarepreservation.org/projects/c_plus_plus/cfront/release_e/doc/ReferenceManual.pdf http://www.softwarepreservation.org/projects/c_plus_plus/cfr..., which shows that the first external C++ release didn't have // comments. The first commercial release had, though (http://www.softwarepreservation.org/projects/c_plus_plus/cfront/release_1.0/doc/ReleaseNotes-Lifeboat.pdf http://www.softwarepreservation.org/projects/c_plus_plus/cfr...)
- ben0x539 10y agoDarn. :P I was only thinking of the standardized ones, but you're correct, of course!
- ajenner 10y ago> you would never use U"hello!" in pre C11/C++11. I have seen real world code which does almost exactly that and which broke (fortunately with a compiler error rather than silently changed code) when compiled with a C++11 compiler due to the new user-defined literal syntax. I agree that it's rare, but it can happen.