Lurker News
Hi HN,

We are members of the C Standard Committee and associated C experts, who have collaborated on a new book called Effective C, which was discussed recently here: https://news.ycombinator.com/item?id=22716068. After that thread, dang invited me to do an AMA and I invited my colleagues so we upgraded it to an AUA. Ask us about C programming, the C Standard or C standardization, undefined Behavior, and anything C-related!
The book is still forthcoming, but it's available for pre-order and early access from No Starch Press: https://nostarch.com/Effective_C.
Here's who we are:
rseacord - Robert C. Seacord is a Technical Director at NCC Group, and author of the new book by No Starch Press “Effective C: An Introduction to Professional C Programming” and C Standards Committee (WG14) Expert.
AaronBallman - Aaron Ballman is a compiler frontend engineer for GrammaTech, Inc. and works primarily on the static analysis tool, CodeSonar. He is also a frontend maintainer for Clang, a popular open source compiler for C, C++, and other languages. Aaron is an expert for the JTC1/SC22/WG14 C programming language and JTC1/SC22/WG21 C++ programming language standards committees and is a chapter author for Effective C.
msebor - Martin Sebor is Principal Engineer at Red Hat and expert for the JTC1/SC22/WG14 C programming language and JTC1/SC22/WG21 C++ programming language standards committees and the official Technical Reviewer for Effective C.
DougGwyn - Douglas Gwyn is Emeritus at US Army Research Laboratory and Member Emeritus for the JTC1/SC22/WG14 C programming language and a major contributor to Effective C.
pascal_cuoq - Pascal Cuoq is the Chief Scientist at TrustInSoft and co-inventor of the Frama-C technology. Pascal was a reviewer for Effective C and author of a foreword part.
NickDunn - Nick Dunn is a Principal Security Consultant at NCC Group, ethical hacker, software security tester, code reviewer, and major contributor to Effective C.
Fire away with your questions and comments about C!

Comments (962) 182 threads

Earlier comments
smlckz1 reply#
I want this feature in the standard.

If there exists any memory block allocated using malloc() / calloc() / realloc() which has not been free()'d, at the end of the program, they would be free()'d automatically.
One can easily do it with keeping a linked list and using atexit(), but, can it be added to the standard?
A general question, will anything, any feature, which is "easy" to implement in pure C, like array knowing its own length or pascal strings, NOT be allowed to be in C standard, even if it is widely used, maybe almost everywhere?

bch1 reply#
The operating system handles this for you on process deletion. Lots of “one shot” programs count on this (and (e.g.) file descriptors being automatically closed).
smlckz#
So, should I not care about that so much, and write programs without free()'ing allocated memory?

If OSes do that, why not standardize that in C?

kazinator1 reply#
CAN I HAZ UNNAMED UNUSED PARAM

   void callback(int x, void *) // VOID STAR UNUZED, SO ANON
   {
      foo(x);
   }
DougGwyn2 replies#
Why is there a second argument which is not used?
wnoise#
To match an API where it is sometimes used.
tropo#
It could be for function pointer type compatibility.

There is an array of pointers, or there is a callback interface, or something like that. The type is set in stone.

tridentboy#
Know it's not exactly related to what you do. But do you have some recommendations of books/online classes to learn C?
ebg131 reply#
How accurate, relevant, and useful today is http://c-faq.com ?
_kst_#
It's a bit dated (it hasn't been updated since 2005), but apart from that I'll say that parts of it are excellent.

In particular, section 6 is the best resource I know of for explaining the often counterintuitive relationship between arrays and pointers.

Load more comments