Red Hat ENTERPRISE LINUX 3 - DEVELOPER TOOLS GUIDE Bedienungsanleitung Seite 10

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 24
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 9
6 Chapter 2. Basic Principles of the Tools
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 as-
sembly 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.
2.6. as, the GNU Assembler
as, the GNU assembler, translates text-based assembly language source files into binary-based object
files. Normally it operates without you being aware of it, as the compiler driver program (gcc) invokes
it automatically. However, if you are creating your own assembler source files, you must invoke as
directly.
If, while using gcc, you want to pass special command-line options to the assembler to control its be-
havior, you need to use the ‘-Wa,<text>’ command-line option. This option passes <text> directly
to the assembler’s command line. For example:
gcc -c -g -O -Wa,-alh,-L file.c
passes the -alh command line option on to the assembler. (This causes the assembler to emit a listing
file that shows the assembler source generated by the compiler for each line of the C source file
file.c).
For more information, refer to Using as, the Gnu Assembler.
2.6.1. Object Files
The assembler creates object files that, by convention, have the .o extension. These are binary files
that contain the assembled source code, information to help the linker integrate the object file into an
executable program, debugging information and tables of all of the symbols used in the source code.
Seitenansicht 9
1 2 ... 5 6 7 8 9 10 11 12 13 14 15 ... 23 24

Kommentare zu diesen Handbüchern

Keine Kommentare