C preprocessor

The C preprocessor (CPP) is a text file processor that is used with C, C++ and other programming tools. The preprocessor provides for file inclusion (often header files), macro expansion, conditional compilation, and line control. Although named in association with C and used with C, the preprocessor capabilities are not inherently tied to the C language. It can and is used to process other kinds of files.[1]

C, C++, and Objective-C compilers provide a preprocessor capability, as it is required by the definition of each language. Some compilers provide extensions and deviations from the target language standard. Some provide options to control standards compliance. For instance, the GNU C preprocessor can be made more standards compliant by supplying certain command-line flags.[2]

The C# programming language also allows for directives, even though they cannot be used for creating macros, and is generally more intended for features such as conditional compilation.[3] C# seldom requires the use of the directives, for example code inclusion does not require a preprocessor at all (as C# relies on a package/namespace system like Java, no code needs to be "included").

The Haskell programming language also allows the usage of the C preprocessor, which is invoked by writing {-# LANGUAGE CPP #-} at the top of the file. The accepted preprocessor directives align with those in standard C/C++.

Features of the preprocessor are encoded in source code as directives that start with #.

Although C++ source files are often named with a .cpp extension, that is an abbreviation for "C plus plus"; not C preprocessor.

  1. ^ General-purpose text preprocessing with the C preprocessor. Featuring JavaScript
  2. ^ "The C Preprocessor: Overview". Retrieved 17 July 2016.
  3. ^ "C# preprocessor directives". Microsoft. 14 January 2022.

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search