Is there any C preprocessor as an independent program?

I know that the C preprocessor exists as part of the compiler. But I am looking for an independent program. Is there such a tool?

+4
source share
6 answers

It is often called cpp . For example, in my Linux window:

 CPP (1) GNU CPP (1)

 NAME
        cpp - The C Preprocessor

 SYNOPSIS
        cpp [-Dmacro [= defn] ...] [-Umacro]
            [-Idir ...] [-iquotedir ...]
            [-Wwarn ...]
            [-M | -MM] [-MG] [-MF filename]
            [-MP] [-MQ target ...]
            [-MT target ...]
            [-P] [-fno-working-directory]
            [-x language] [-std = standard]
            infile outfile

This particular item is part of gcc and is available across a wide variety of platforms.

+10
source

You can also watch m4

What is m4?

M4 can be called "template language", "macro language" or "preprocessor language". The name "m4" also refers to a program that processes texts in this language: this "preprocessor" or "macro processor" takes the m4 template as input and sends it to the output after the action to any built-in directives called macros.

+3
source

mcpp .

On the home page:

mcpp is a C / C ++ preprocessor with the following functions.

  • Implements all specifications of C90, C99 and C ++ 98.
  • Provides a validation package to verify compliance and quality of the C / C ++ preprocessor. When this validation package is applied, mcpp stands out among many existing preprocessors.
  • It has sophisticated and targeted diagnostics to check all problems with preprocessing, such as a hidden error or lack of portability in the source code.
  • Has #pragma directives for outputting debugging information.
  • Portable and portable to many compiler systems, including GCC and Visual C ++, on UNIX-like systems and Windows.
  • It has various behaviors.
  • It can be designed either as a compiler-specific preprocessor to replace the resident preprocessor of a particular compiler system, as a compiler-independent command, or> even as a subprogram called from some other main program.
  • Provides comprehensive documents in both Japanese and English.
  • This is open source software released under the BSD license.
+2
source

I used filepp to preprocess files other than direct C. This is a Perl module, so it is quite portable. It’s convenient in that you can use all the familiar idioms that you’re used to, and adds some useful features.

On the website:

Why filepp and not plain old cpp?

cpp is designed specifically to generate output for the C compiler. Yes, you can use any type of file with it, but the output it creates includes loads of empty lines and lines style:

# 1 "file.c"

Obviously, these lines are very useful to the C compiler, but not used in the HTML file. In addition, since filepp is written in Perl, it is 8-bit pure and therefore works on any character set, not just ASCII characters. filepp is also customizable and hopefully more user friendly than cpp.

+2
source

cpp is just one. This is a split program called gcc at compilation.

+1
source

This is part of the package and is usually called cpp (C PreProcessor).

 which cpp # /usr/bin/cpp man cpp 
+1
source

All Articles