logoalt Hacker News

uecker • today at 12:25 PM • 4 replies • view on HN

Any tutorial for C should explain compiler warnings and other tools that help make code safer. In C, you do not rely on the language specification but on tooling. Especially for Rust programmers, this needs to be explained more explicitly. And of course, you can build abstractions using types in C. So a tutorial should also focus on that, and perhaps not start with a low-level string reversal function.


Replies

swinglock • today at 1:31 PM

Absolutely. Turn the warnings into errors too, build and test with sanitizers (ASAN, UBSAN, TSAN) when not measuring performance, and use static analysis beyond compiler warnings (Clang Tidy, Clang Static Analyzer).

Though the author doesn't look to be trying to write a great tutorial, rather prioritizing sharing what and how they learned something from their perspective.

➕ show 2 replies
bjackman • today at 1:15 PM

> This is not a substitute for a proper C tutorial

kingforaday • today at 1:11 PM

I'm with you. Since the post already shows Clang catching the array-decay bug, the author could even just add a “always build with -Wall -Wextra -fsanitize=address,undefined” note and some explanation of course.

jminnl • today at 1:43 PM

Asan!