Hacker News new | ask | show | jobs
by janoc 2117 days ago
It is not and never was.

Look at for ex. what const means in each, or auto. Or variable length arrays (feature that doesn't exit in C++). Or designated initializers that C++ didn't have for a long time.

Here is a good list of differences: https://mcla.ug/blog/cpp-is-not-a-superset-of-c.html

1 comments

C++ is almost a perfect superset of old C before C99. There are odd corner cases where prograns are parsed differently, but these are quite contrived. The 3rd edition of The C++ Programming language lists a few cases. Since then, C has had may additions to the language that made it diverge from C++. Your linked article is almost entirely about these new C additions.
Even for the old C it wasn't a superset.

There are plenty of legal C programs that aren't legal C++ - if for nothing else, then because C++ has more reserved keywords which are perfectly legal identifier names in C.

E.g. this is legal C but not legal C++:

int template = 10;