Mini C compiler written in C++23, targeting x86_64 architecture.
Getting Started
Prerequisites
- Clang (any version compatible with C++23)
make
- Pthread Support (the build uses the -pthread flag)
Optional (for running unit tests)
- Google Test (gtest) for running unit tests.
Installation
- Clone the repository:
git clone https://github.com/rdkc4/minicpp.git
cd minicpp
- Build the project: or (recommended, to use all available cores for a faster build):
Usage
To compile a source file, run:
./minicpp <source-file> # Default output file: output.s
Alternatively, you can specify a custom output file:
./minicpp <source-file> <output-file>
Where:
- <source-file> - file you want to compile (e.g. testfile.txt)
- <output-file> - optional output file name (defaults to output.s if not provided)
Creating an executable:
# assemble to object file
as output.s -o output.o
# link to create executable
ld output.o -o executable
Running the executable:
# run the executable
./executable
# print return value
echo $?
Unit Tests (optional)
Running the tests: