cpp-4.8
Preprocess C and C++ source code
SYNOPSIS
cpp-4.8 [options] <input_file> [<output_file>]
PARAMETERS
-D<macro>[=<value>]
Define a macro with an optional value. If no value is specified, the macro is defined as '1'.
-U<macro>
Undefine a macro, even if it was previously defined on the command line or in the source code.
-I<dir>
Add <dir> to the list of directories searched for header files during file inclusion.
-M
Output a rule suitable for make describing the dependencies of the main source file (i.e., its header files). System headers are included.
-MM
Similar to -M, but excludes system header files from the dependency list.
-MD
Like -M, but also compile the source file. The dependencies are written to a file named <file>.d by default, or specified by -MF.
-MMD
Like -MM, but also compile the source file. Dependencies are written to a .d file, excluding system headers.
-MF <file>
When used with -M, -MM, -MD, or -MMD, specifies the output file for the dependency information.
-MT <target>
Change the target of the rule emitted by -M or -MM. Useful for custom build systems.
-MQ <target>
Like -MT, but quotes special characters in <target> for use in makefiles.
-P
Inhibit generation of # line markers. Useful for producing cleaner output for human inspection or other tools.
-C
Do not discard comments during preprocessing. Comments will be preserved in the output.
-CC
Like -C, but also preserve comments that appear within macro arguments, even if the macro expands to nothing.
-E
Run only the preprocessor. This is often implicit when invoking cpp-4.8 directly.
-H
Print the name of each header file as it is used, indicating the order of inclusion.
-v
Enable verbose output, showing the command's internal components, search paths, and other diagnostic information.
--version
Display the preprocessor's version information and exit.
-std=<standard>
Conform to the specified C or C++ language standard (e.g., c99, c++03). This affects specific preprocessor behaviors related to the standard.
DESCRIPTION
The cpp-4.8 command invokes the C Preprocessor component from the GNU Compiler Collection (GCC) version 4.8. It is the first stage of the compilation process for C, C++, and Objective-C programs. Its primary role is to handle preprocessing directives embedded in source code, transforming the original source file into an intermediate form before actual compilation.
Key functions of the preprocessor include:
Macro Expansion: Replacing defined macros with their corresponding text.
File Inclusion: Incorporating content from specified header files (e.g., via #include directives).
Conditional Compilation: Including or excluding blocks of code based on conditions (e.g., using #if, #ifdef, #ifndef, #else, #elif, #endif).
Line Control: Generating # line directives to aid debuggers and tools by indicating the original source file and line numbers.
CAVEATS
The cpp-4.8 command refers to a specific version (4.8) of the GNU C Preprocessor. On modern Linux distributions, the default cpp command typically points to a much newer GCC version. This specific version might be present on older systems or within environments configured for legacy software development.
While cpp-4.8 functions as a standalone preprocessor, it is most commonly invoked implicitly by the gcc or g++ compiler driver commands as part of the overall compilation process. Its output is typically fed directly into the next stage of compilation (the compiler itself), rather than being stored as a separate file unless specifically requested with options like -E and redirection.
PREPROCESSING STAGES
The preprocessing stage is the first of several stages in the compilation of C/C++/Objective-C code. The typical sequence is:
1. Preprocessing (by cpp): Handles directives, macros, and includes.
2. Compilation (by cc1/cc1plus): Converts preprocessed code into assembly code.
3. Assembly (by as): Converts assembly code into machine code (object files).
4. Linking (by ld): Combines object files and libraries into an executable or shared library.
OUTPUT FORMAT
When cpp-4.8 is run with -E, its output is a single, expanded source file. This file contains all included header content, all macro expansions, and conditionally compiled code. By default, it also includes # line directives that specify the original source file and line number for each line of code, which is crucial for debugging and error reporting later in the compilation process.
HISTORY
The concept of a preprocessor dates back to the early days of the C language. Originally, it was often a separate program or a very simple initial pass. With the advent of the GNU Compiler Collection (GCC), the C preprocessor (cpp) became an integrated, yet distinct, component.
GCC's development has been continuous, with major version releases marking significant advancements. Version 4.8, released around 2013, was a stable and widely adopted release of GCC, introducing new features and improved C++11/C++14 support. The cpp-4.8 command specifically identifies the preprocessor binary associated with that particular GCC release. While newer GCC versions (and thus newer cpp versions) exist, the core functionality and syntax of the C preprocessor have remained largely consistent since the C standard (C89/C90), ensuring broad compatibility across different cpp versions for standard C/C++ code.


