alexfru/SmallerC logo

alexfru/SmallerC

Free

Simple C compiler

FreeFree tier
Type
Open Source

About alexfru/SmallerC

Smaller C is a simple, small, single-pass C compiler that supports most of the C language shared between C89/ANSI C and C99 (with some exclusions from C89 and additions from C99). It generates 16-bit and 32-bit 80386+ assembly code for NASM (alternatively YASM or FASM) for DOS, Windows, Linux, and macOS executables. MIPS code generation is also available, primarily for RetroBSD. The compiler is self-hosting and includes a preprocessor (ucpp), a linker, and a compiler driver with gcc-like options. The standard C library is work in progress but nearing completion.

Key Features

Single-pass C compiler supporting C89 and C99 (subset)
Generates 16-bit and 32-bit x86 assembly for NASM, YASM, or FASM
MIPS code generation for RetroBSD
Self-hosting (can compile its own source code)
Includes preprocessor (ucpp), linker, and compiler driver with gcc-like options
Targets DOS, Windows, Linux, and macOS
Standard C library nearing completion

Pros & Cons

Pros
  • Small and simple codebase, easy to understand and modify
  • Self-hosting capability ensures reliability
  • Multi-target output: x86 (16/32-bit) and MIPS assembly
  • Includes complete toolchain (preprocessor, compiler, assembler, linker)
  • Open source under permissive BSD-2-Clause license
  • GCC-like driver options for familiar workflow
Cons
  • Not compliant with full C99 or later standards; lacks some C89 features
  • Standard C library is still work in progress
  • Only generates assembly for x86 and MIPS; no ARM/RISC-V support
  • Project may have limited ongoing maintenance (last release Aug 2024)
  • Requires external assembler (NASM, YASM, or FASM) to produce executables

Best For

Compiling C programs for legacy DOS and modern Windows/Linux/macOSDeveloping for MIPS-based embedded systems like RetroBSDLearning compiler construction and designSelf-hosting development and bootstrappingBuilding small footprint executables

FAQ

What C standards does Smaller C support?
It supports most of the C language common between C89/ANSI C and C99, minus some C89 features and plus some C99 features.
Can Smaller C compile itself?
Yes, the compiler is self-hosting and can compile its own source code.
What target platforms can Smaller C generate code for?
It generates 16-bit and 32-bit 80386+ assembly for DOS, Windows, Linux, and macOS. MIPS CPU code generation is also supported, primarily for RetroBSD.
What assembler is needed?
Smaller C outputs NASM assembly. You may also use YASM or FASM instead of NASM.
Is the standard C library included?
A standard C library is included and is close to completion but still considered work in progress.