6 ms·
C++ isn't strictly a superset of C! Which I always found crazy. Some C will not compile for C++.
by frostirosti 9y ago
C++ isn't strictly a superset of C! Which I always found crazy. Some C will not compile for C++.
- YSFEJ4SWJUVU6 9y agoWhy did you find that crazy? They are 2 fully separate languages that have both evolved after the latter (C++) was first introduced.
- EnFinlay 9y agoFor people who aren't professionally familiar with C or C++ it's an easy mistake to make considering how often things refer to "C/C++" like they are a single skill. Example: https://sjobs.brassring.com/TGWebHost/jobdetails.aspx?jobId=342549&PartnerId=25872&SiteId=5512 https://sjobs.brassring.com/TGWebHost/jobdetails.aspx?jobId=...
- jacquesm 9y agoOnce upon a time there was this thing called 'cfront'. Cfront took C++ and turned it into C which you then fed through your compiler. At that time mixing C and C++ was trivial, especially because C++ was still quite simple and the C compiler was the target. But after that things got more complicated. C evolved, several times in fact since that time and the C++ standard evolved as well. Leading to the impression that C and C++ are merely the old and the improved version of C but it is probably much better to think of them as two distinct species that share a common ancestor, where one of the two had some very radical mutations.
- loeg 9y agoIt would be relatively easy for C++ to add some kinds of C compatibility, and they just haven't bothered to. (E.g., the "static" keyword for parameter array sizes.) It's a little annoying for shared headers that have to be used in C and C++ programs.
- elastic_church 9y ago"5 years of Java/Javascript, with emphasis on PHP" Contact Pro IT Recruiting where we know our candidates, Referral bonuses too!
- dfrey 9y agoWhen people use the term "C/C++", I assume that they don't know either language well.
- TorKlingberg 9y agoI wouldn't call them "fully separate". Mixed C/C++ codebases are still fairly common, which works as long as the interface between them is in C.
- astrodust 9y agoMixed C, Objective C and C++ code-bases are still fairly common. That's not to say they're the same language.
- umanwizard 9y agoWell, your argument doesn't really prove anything, as Obj-C is actually much closer to C than C++ is.
- w8rbt 9y agoThey have separate ISO standards. IMO, this makes them fully separate. C - ISO/IEC 9899:2011 C++ - ISO/IEC 14882:2014
- AnimalMuppet 9y agoBut the standards have made some effort at avoiding gratuitous incompatibility, and have even introduced changes to reflect changes in the other standard. Also, much C code is still valid C++. Sure, you can write code that isn't, but I would guess (pulls a number out of nowhere) that 90% of the valid C code is also valid C++. That makes them languages that have separate standards, but not completely independent standards, that share a whole lot of source code. That's something less than fully separate in my book.
- deleted 9y ago[deleted]
- samfisher83 9y agoCan you provide C code that will not compile with c++ compiler?
- msoucy 9y agoSure: struct Foo { int virtual; };
- metaobject 9y agoYou're being pedantic about reserved words?
- spc476 9y agoI had that same problem. I wrote a C library [1] that has a structure field named "class". It's "class" because the protocol being described (DNS) calls that particular field "class" [2]. And I'm not about to pay lip service to an abomination like C++ [3][4]. [1] https://github.com/spc476/SPCDNS https://github.com/spc476/SPCDNS [2] https://github.com/spc476/SPCDNS/blob/ca5052c3d0c3252071a18ebbada808a7b536c860/src/dns.h#L255 https://github.com/spc476/SPCDNS/blob/ca5052c3d0c3252071a18e... [3] I am NOT a fan of C++. [4] But I had to anyway, but I used the C pre-processor to rename the field.
- camgunz 9y agoYeah I super hate this. There's no other language that requires other languages to contort themselves like C++ does. Every time I see `#ifdef __cplusplus` or `klass` my blood pressure spikes.
- astrodust 9y agoHere's a bunch of examples: http://www.geeksforgeeks.org/write-c-program-wont-compiler-c/ http://www.geeksforgeeks.org/write-c-program-wont-compiler-c...
- Chromozon 9y ago
- bobbyi_settv 9y agoIt would be hard for it to be a completely strict superset of C because that would require not introducing new reserved words (like "class") since those end up being legal variable names in C but not C++.