Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

2.5. cpp, the GNU Preprocessor

cpp is a C-compatible macro preprocessor that works with the GNU compiler to direct the parsing of C preprocessor directives. Preprocessing directives are the lines in your program that start with a # directive name (a # sign followed by an identifier). For instance, cpp merges #include files, expands macro definitions, and processes #ifdef sections. Another example is #define, a directive that defines a macro (#define must be followed by a macro name and the macro's intended expansion).

To refer to the output of cpp, invoke gcc with the -E option; the preprocessed file will print on stdout

The C preprocessor provides the following separate facilities:

  • Inclusion of header files — Declarations that can be substituted into your program.

  • Macro expansion When defining macros, which are abbreviations for arbitrary fragments of C code, the C preprocessor replaces them with their definitions throughout a program.

  • Conditional compilation — Using special preprocessing directives, include or exclude parts of a program according to replaceableious conditions.

  • Line control — Using a program to combine or rearrange source files into an intermediate file that is then compiled, use line control to provide a source line's origin.

There are two convenient options to assemble files that require C-style preprocessing. Both options depend on using the compiler driver program, gcc, instead of directly calling the assembler.

  • Name the source file using the extension .S (capitalized), rather than .s (the .S indicates an assembly language program that requires C-style preprocessing).

  • Specify a source language explicitly for a situation, using the -xassembler-with-cpp option.

For more information on cpp, refer to Using cpp, the C Preprocessor.

 
 
  Published under the terms of the GNU General Public License Design by Interspire