Hacker News new | past | comments | ask | show | jobs | submit login

Essential C doesn't mention a standard but it says Copyright 1996-2003. I'm going guess it hasn't been updated for C11.

Modern C [1] covers C11 and was mentioned before. However, it weighs in at 300 pages rather than Essential C's 45.

[1] http://icube-icps.unistra.fr/img_auth.php/d/db/ModernC.pdf

Actually, reading through Essential C, it hasn't really been updated for C99 since it uses C89 declarations:

  C takes the middle road -- variables may be declared
  within the body of a function, but they must follow a
 '{'. More modern languages like Java and C++ allow you
  to declare variables on any line, which is handy.



I don't know if I would count any part of C11 as "essential", particularly given its still-spotty implementation coverage.


A 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.


C99 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.


I do love object literals. The 'static' keyword for array parameters actually dates to the C99 standard.


You're 100% correct, my mistake.


And 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.


What portability do you need, specifically, beyond C99?


A lot of compilers for embedded systems are still C89 (with a few architecture-specific extensions).


Which systems, specifically?


Until 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.


Yep, 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_2...


You 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.


Sorry to update you, but Microsoft has dropped that frontend.

They now advise to use clang directly, since its Windows support has been improved.


You 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++), ...




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: