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#

  • make, the classic.

  • CMake, portable, generates Makefiles / Ninja / IDE projects.

  • Meson, modern build system, paired with Ninja.

  • Ninja, fast, low-level builder.

Package Managers#

C has no built-in package manager. Common options.

  • vcpkg, Microsoft-maintained, cross-platform.

  • Conan, C/C++ dependency manager with binary caching.

  • System package managers (apt, brew, pacman) plus pkg-config.

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 -i src/*.c

Debugging#

  • gdb, GNU debugger.

  • lldb, LLVM debugger (default on macOS).

  • Valgrind, memory error and leak detector.

  • rr, record-and-replay debugging.

Testing#

  • Unity, minimal C unit test framework.

  • Check, xUnit-style framework.

  • Criterion, modern, header-only.

Editor Support#

  • clangd, LSP backed by Clang.

  • ccls, alternative C/C++ language server.

  • Use compile_commands.json (generated by CMake or bear) so the LSP knows your build flags.