back

by Narishma·12y ago·view on hn ↗
He keeps saying C but the source code he shows at the end is clearly C++, even if the file has a .c extension.
1 comments
Yeah, I see that confusion quite often.
It is quite annoying, especially since C++ was not a superset of C for a long time.

Those are two different languages that just happen to have same roots.

Technically, you're right, but practically you don't have to give up much to write C99 that is also valid C++11.
From my own experiences writing either language I have to disagree. C++ may be much (much much) more featureful than C, but if you skip constructs and behavior that aren't strictly a subset of the two you are still missing a lot of modern C, and it's exaggerated by C11. That's not just the obvious high level features like compound literals, designated initializers, VLAs, or anonymous structures/unions. There are a lot of creeping nits about what is defined and undefined in either language, a famous(ly misunderstood) example being type-punning via union, which is allowed in C but undefined behavior in C++.

Except for a few things C++ has imported from C like stdint and vararg macros the truth of your statement depends strongly on how far you personally tend to stray beyond C89 in either direction.