Lurker News
I have 15+ years of experience in many languages: javascript, python, go, etc.

I can write C, but I'm not confident I'm doing it the right way. There are now decades of forums and blogs I can search through, but I'd love to have a single, clean, clear source of truth for recommendations on how to write C code.
I've started reading "Modern C" by Jens Gustedt. I'm not sure if this is the closest to a modern source of truth.
Note, I'd like my C code to work on Windows, which possibly restricts the "right way" to features provided by C89. But again, I'm not sure, the internet is super clear on this.
Thanks for the tips!

Comments (199) 63 threads

Earlier comments
drran#
I use C since 1992, but I never confident in my C code, unless it heavy with macros to check error codes and return early, register memory allocations and free memory at return, and so on. Rust improved my confidence in C code a lot, but it looks more like Rust code now.
stephc_int13#
In my opinion, one of the main reasons C looks old and not practical to beginners is the standard libs API.

But it is perfectly possible to use C as a language with a more modern and easier to read API, but you'll probably have to build your own.

Nursie#
There are other compilers for windows than MSVC++, so you can move beyond C89 if you wish.

stdint.h is useful and should be required reading. I still come across too many C projects that reimplement it poorly.
Learn to use valgrind, and maybe ddd too.

jfkebwjsbx#
You can compile with clang on Windows, so you can use later standards.

Load more comments