6 ms·
I don't know if I would count any part of C11 as "essential", particularly given its still-spotty implementation coverage.
by bangonkeyboard 9y ago
I don't know if I would count any part of C11 as "essential", particularly given its still-spotty implementation coverage.
- CalChris 9y agoYou might be right. I looked up my favorite modern C feature and it is intermingled declarations and code which is in C99. Others include inline functions, // comments (which were in C++), ...
- userbinator 9y agoA lot of code is still written in C89 for maximum portability, and I regularly do that. The only thing I really miss from C99 is the mixed declarations and code, but you can instead use nested scopes or just move the declarations up to the top.
- bangonkeyboard 9y agoC99 object literals are also fantastic. I feel very constrained when I have to use strict C89. Meanwhile, in terms of C11 [update: actually also from C99] I actually wrote a function with a signature like void func(int arg[static 3]); but later removed it because (a) the generated code was the same, and (b) rather than increasing clarity and self-documentation, it caused confusion; even when you're familiar with the feature, it never stops looking like a syntax error.
- loeg 9y agoI do love object literals. The 'static' keyword for array parameters actually dates to the C99 standard.
- bangonkeyboard 9y agoYou're 100% correct, my mistake.
- pcwalton 9y agoWhat portability do you need, specifically, beyond C99?
- userbinator 9y agoA lot of compilers for embedded systems are still C89 (with a few architecture-specific extensions).
- pcwalton 9y agoWhich systems, specifically?
- sclangdon 9y agoUntil recently, even MSVC was C89. I believe they only added some C99 features because the C++11 standard required them (in VS2013, I believe), and full C99 support only came with VS2015.
- pjmlp 9y agoYep, their focus is on C++ compatibility. They have changed their view regarding C, but the actual work is customer driven. https://www.reddit.com/r/cpp/comments/75q5wc/visual_studio_2017_version_154_released/ https://www.reddit.com/r/cpp/comments/75q5wc/visual_studio_2...
- simias 9y agoAnd stdint.h, variadic macros, restrict, inline (admittedly less necessary as compilers become more clever), flexible array members... I mainly still stick to variable declaration at the beginning of the block out of habit but it would be a pain for me to go back to C89 and forsake all these other nice features.
- jchb 9y agoYou are partly right about the implementation coverage. For a lot of embedded development where you can't cross compile with a modern compiler it's of course an issue. For major desktop and mobile platforms, I don't see an issue. Clang has excellent support for the mandatory parts of C11, it's even the default setting (well GNU C11). Given that one can now configure Clang as the frontend for Visual Studio on Windows, the backwardness of Visual studio in regards to modern C standards is no longer an issue as well. For essential features, well if one uses C it's usually to have fine-graded control of memory use and allocation patterns. Then C11 _Alignas, and _Alignof are pretty essential. Yes you can do that with platform/compiler specific macros without C11, but it's nice to be able to avoid that.
- pjmlp 9y agoSorry to update you, but Microsoft has dropped that frontend. They now advise to use clang directly, since its Windows support has been improved.