Portable C & Compiler Warnings
Portable C runs correctly on every conforming implementation — same output on GCC/Clang/MSVC, 32- and 64-bit, little- and big-endian. The practices: fixed-width stdint.h types for layout-sensitive data, no reliance on signed overflow or evaluation order, explicit sizes in I/O (%zu, not %d), and feature-test macros for platform code.
Warnings are the enforcement arm: -Wall -Wextra -Werror plus -pedantic turns assumptions into build failures, while -Wconversion and -Wshadow audit narrowing and hiding. Portable code plus maximal warnings is the closest C gets to a safety net.
Types that travel
int32_t/uint64_t for layouts and protocols; plain int/long only where the platform genuinely decides.
No UB dependence
Never rely on overflow wraparound, evaluation order (f(i++, i)), or null arithmetic — all vary by compiler.
Warnings as errors
-Wall -Wextra -Werror -pedantic in every build — new warnings break the build the day they appear.
Audit extras
-Wconversion (narrowing), -Wshadow (hiding), -Wsign-compare (mixed signs) — enable per project, fix deliberately.
#include <stdio.h>#include <stdint.h> int main(void) { int32_t a = 2000000000; int64_t b = (int64_t)a * 2; printf("%lld\n", (long long)b); return 0;}Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in C yourself — building beats watching.