C++ is not a superset of C
31–40 of 114 posts
Re: C++ is not a superset of C
#32Re: C++ is not a superset of C
#33That pink background to the left weighs 6 MB. Do you really think it's necessary?
Re: C++ is not a superset of C
#34Nearly everything that is mentioned in this blog is a subject of change / addition to the latest C standard, code named C2x. They are in discussions to introduce the following in C: * nullptr * auto * __has_include * make false and true first-class language features * constexpr and lots of other goodies [1]. https://gustedt.wordpress.com/2018/11/12/c2x/
Re: C++ is not a superset of C
#35The code: const size_t buffer_size = 5; int buffer[buffer_size]; compiles fine in c, but not for the same reason. C99/C11 has dynamic arrays https://en.wikipedia.org/wiki/Variable-length_array#C99
Re: C++ is not a superset of C
#36One recent difference I saw was valid in (via GNU C extension) but invalid in c++:
struct foo my_foo = ({
init(&my_foo);
my_foo;
});Re: C++ is not a superset of C
#37Re: C++ is not a superset of C
#38Several of the examples shown as valid C are not. For example, this: const int foo = 1; int* bar = &foo; *bar = 2; is said to have undefined behavior, but in fact the initialization of `bar` is a constraint violation, requiring a diagnostic. (Some compilers will issue a non-fatal warning, which is allowed by the C standard but IMHO is unfortunate.) Another example: it says that this: const size_t buffer_size = 5; int…
GCC 5.1.0 reports:
warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]Re: C++ is not a superset of C
#39 int arr[3] = { [1] = 5 }
or even struct A c = {.x = 1, 2}
or another example where the designators are not declared in order of the struct members, or where the designators are nested. The version of designated initializers standardized in C++20 only allows the simple case that's currently implemented in all the major compilers.See https://stackoverflow.com/a/29337570 for more info and examples.
Re: C++ is not a superset of C
#40I never heard anyone say that C++ is a superset of C. Sure, the first version was a preprocessor on top of C and certainly that is common knowledge. But a superset? Never heard it. ObjC on the other hand...
- C++ is a superset of C, and that virtually any legal C program is a legal C++ program. https://www.tutorialspoint.com/cplusplus/cpp_overview.htm
- "C is a subset of C++." / "C++ is a superset of C." https://www.geeksforgeeks.org/difference-between-c-and-c/
- "C++ is a superset of C; (almost) anything you can do in C, you can do in C++." https://www.cprogramming.com/begin.html
- "As you recall C is a root for C++ and C++ is a superset of C." https://www.c-sharpcorner.com/article/similarities-and-diffe...