Tooling#
C has no standard toolchain; instead it has a small ecosystem of compilers, build systems, and analysis tools that interoperate well.
Compilers#
GCC, the GNU Compiler Collection.
Clang, LLVM’s C front end.
MSVC, Microsoft’s compiler.
tcc, tiny, fast C compiler.
$ cc -std=c17 -Wall -Wextra -O2 -o app main.c
Build Systems#
Package Managers#
C has no built-in package manager. Common options.
Static Analysis#
clang-tidy, linter and modernizer.
cppcheck, standalone static analyzer.
scan-build, Clang static analyzer.
Compiler warnings:
-Wall -Wextra -Wpedantic -Wshadow -Wconversion.
Sanitizers#
Compile-time instrumentation that catches bugs at runtime.
$ cc -fsanitize=address,undefined -g -O1 main.c -o app
-fsanitize=address, AddressSanitizer (heap/stack errors)-fsanitize=thread, ThreadSanitizer (data races)-fsanitize=undefined, UndefinedBehaviorSanitizer-fsanitize=memory, MemorySanitizer (Clang only)
Formatting#
clang-format, source formatter.
$ clang-format -i src/*.c