On Thu, 12 Oct 2017 02:43 am, Marko Rauhamaa wrote: > Chris Angelico <ros...@gmail.com>: > >> The places where C++ is not a superset of C are mostly things you >> wouldn't want to be doing anyway. You can generally take C code and >> compile it with a C++ compiler, and it'll have the same semantics. > > Here's a C/C++ program: > > ======================================================================== > #include <stdio.h> > > int main() > { > struct {} s; > printf("%d\n", (int) sizeof 'a'); > printf("%d\n", (int) sizeof s); > return 0; > } > ======================================================================== > > When compiled (with gcc) as a C program, the output is: > > 4 > 0 > > When the same program is compiled (with gcc) as a C++ program, the > output is: > > 1 > 1 > > That is not immediately all that significant but points to subtle > incompatibilities between the data models of C and C++.
I don't think anyone should expect that platform specific details like the size of a char should be precisely the same between C and C++. Even two different C compilers could return different values. > Then we have syntactic problems: [...] I don't believe that anyone meant to imply that C++ is an exact superset of C. I know I didn't, although I acknowledge that my terminology was lazy. C++ is broadly-speaking compatible with C, with just enough differences to act as landmines to the unwary. Good enough? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list