4 ms·
> C/C++ This is specifically about the C programming language. Can we not conflate it with a different language entirely, at least in this comment thread?
by derleth 15y ago
> C/C++
This is specifically about the C programming language. Can we not conflate it with a different language entirely, at least in this comment thread?
- Retric 15y agoI was under the impression the C++ standard moves in lockstep with C so that all valid C programs should also be valid C++ programs.
- adrianN 15y agoI believe that has not been true for a long time, at the very least because some things are keywords in C++ that would be valid identifiers in C.
- Retric 15y agoYea, after looking into it they don't seem to be completely compatible anymore. I have known many people to use a C++ compiler when writing C code, but it looks like that restricts you to a subset of C. They do try and stay reasonably consistent so for example Long Long moved from C to C++. And C99 has reduced some other incompatibilities by incorporating C++ features such as // comments and mixed declarations and code. http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B
- Someone 15y ago"I have known many people to use a C++ compiler when writing C code, but it looks like that restricts you to a subset of C." Many C++ compilers actually are C/C++ compilers that decide what language to compile depending on command line flags and/or file name extension.
- Retric 15y agoAhh, ok now that explains a lot, thanks.
- natesm 15y agoThat's Objective-C. int* foo = malloc(sizeof(int)); Is invalid C++.
- chimeracoder 15y agoI don't really know C++ as well as I know C - could you explain? I always thought that the only real reason C++ wasn't a superset is because of the additional keywords.
- wollw 15y agoC++ doesn't coerce the void* malloc returns into an int* , C does. You have to write int* foo = (int*)malloc(sizeof(int)); in C++ or the compiler gives a type error.