/c-language-preprocessor

This is a simple C/C++ preprocessor. The goal is to have good conformance with the C and C++ standards and to handle nonstandard preprocessor extensions in gcc / clang / visual studio preprocessors. Most of the preprocessor testcases in gcc and clang are handled OK by so-cpp.

Primary LanguageCGNU General Public License v3.0GPL-3.0

C Language Preprocessor

This is a simple C/C++ preprocessor. The goal is to have good conformance with the C and C++ standards and to handle nonstandard preprocessor extensions in gcc / clang / visual studio preprocessors. Most of the preprocessor testcases in gcc and clang are handled OK by so-cpp.

📝 Table of Contents

🧐 About

The C Preprocessor is not a part of the compiler, but is a separate step in the compilation process. In simple terms, a C Preprocessor is just a text substitution tool and it instructs the compiler to do required pre-processing before the actual compilation.

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

To run the preprocessor on your computer you must have:

  • for UNIX based operating systems:
  • for Windows operating system:
    • cl - is a tool that controls the Microsoft C++ compiler and linker

Installing

This is a step by step series of examples that tell you how to get a development env running.

  • Linux:
    • start by updating the packages list
      $ sudo apt update
    • install the build-essential package(a package of new packages including gcc, g++ and make) by typing:
      $ sudo apt install build-essential 
  • Windows:

🔧 Running the tests

If you want to run the automated tests for Linux system you must follow the following steps:

  • clone the repository by copping the following command in your terminal:
    git clone https://github.com/gabriel-rusu/C-Language-Preprocessor.git
  • go into the project director and run the following command:
    $ make test
  • now in the test director a new folder _test/outputs has appeared containing the results.

The purpose of the test suite is to show the preprocessing of .c and .h files from the _test/inputs folder. The results of the preprocessed files is then compared with the CPP output (utilitary of GCC that is used to preprocess the .c and .h files for the GCC compiler)

🎈 Usage

To use the preprocessor on other files, simply use the following command:

    ./so-cpp < your-input-file.in >your-output-file.out

where:

  • your-input-file.in - is a custom input file
  • your-output-file.out - is the result of pteprocessing the input file

⛏️ Built Using

  • Visual Studio Code - code editor
  • GCC - used to compile the program on my Linux machine
  • CPP - preprocessing utility used to test the program output

✍️ Author