clang

Compiler for C, C++, and Objective-C source files. Can be used as a drop-in replacement for GCC. More information: <https://clang.llvm.org/docs/ClangCommandLineReference.html>.

Install

All systems
curl cmd.cat/clang.sh
Debian Debian
apt-get install clang
Ubuntu
apt-get install clang
Alpine
apk add clang
Arch Arch Linux
pacman -S clang
image/svg+xml Kali Linux
apt-get install clang
CentOS
yum install clang
Fedora
dnf install clang
Windows (WSL2)
sudo apt-get update sudo apt-get install clang
Raspbian
apt-get install clang
Docker
docker run cmd.cat/clang clang powered by Commando

Compiler for C, C++, and Objective-C source files. Can be used as a drop-in replacement for GCC. More information: <https://clang.llvm.org/docs/ClangCommandLineReference.html>.

  • Compile a source code file into an executable binary:
    clang input_source.c -o output_executable
  • Activate output of all errors and warnings:
    clang input_source.c -Wall -o output_executable
  • Include libraries located at a different path than the source file:
    clang input_source.c -o output_executable -Iheader_path -Llibrary_path -llibrary_name
  • Compile source code into LLVM Intermediate Representation (IR):
    clang -S -emit-llvm file.c -o file.ll
  • Compile source code without linking:
    clang -c input_source.c
  • Optimize the compiled program for performance:
    clang path/to/source.c -O1|2|3|fast

© tl;dr; authors and contributors