4 ms·
Sure, I like many of the new features of C++ that could be compatible with or adapted to C (constexpr, auto, typed enums, or even (gasp).. templates for generic
by makapuf 10y ago
Sure, I like many of the new features of C++ that could be compatible with or adapted to C (constexpr, auto, typed enums, or even (gasp).. templates for generic programming) and I'm jealous of the level of innovation in C++ (which would't be that difficult to backport to C since the features already are on C++), especially for embedded.
- vopi181 10y agoWhy wouldn't you just use c++ then? Almost all c++ is valid C, no?
- astrodust 10y agoA lot of people write C in C++ mode just for convenience, you get things like const, but it's not the same as writing actual standards compliant C code. If you need portable C code, forget about all that stuff. Forget about a lot of things since some compilers are truly atrocious.
- khedoros1 10y agoAlmost all C is valid C++, but the reverse isn't true.
- makapuf 10y agoAlmost but not all. Restrict keyword, by example.
- dangerbird2 10y agoAlso modern features like atomics and complex numbers are implemented as language features in C, but with template libraries in C++. Likewise type-generic math in C11 uses the C-specific _Generic keyword, but uses templates and function overloading in C++