Datasheet

Book VIII
Chapter 1
Programming
in Linux
535
Exploring the Software-Development Tools in Linux
A host of GCC options controls various aspects of compiling C and C++
programs.
Exploring GCC options
Here’s the basic syntax of the gcc command:
gcc options filenames
Each option starts with a hyphen (-) and usually has a long name, such
as -funsigned-char or -finline-functions. Many commonly used
options are short, however, such as -c, to compile only, and -g, to gener-
ate debugging information (needed to debug the program by using the GNU
debugger, gdb).
You can view a summary of all GCC options by typing the following com-
mand in a terminal window:
man gcc
Then you can browse through the commonly used GCC options. Usually,
you don’t have to provide GCC options explicitly because the default set-
tings are fine for most applications. Table 1-1 lists some of the GCC options
you may use.
Table 1-1 Common GCC Options
Option Meaning
-ansi
Supports only ANSI standard C syntax. (This option
disables some GNU C-specific features, such as the
__asm__ and __typeof__ keywords.) When used
with g++, supports only ISO standard C++.
-c
Compiles and generates only the object file.
-DMACRO Defines the macro with the string “1” as its value.
-DMACRO=DEFN Defines the macro as DEFN, where DEFN is some text
string.
-E
Runs only the C preprocessor.
-fallow-single-
precision
Performs all math operations in single precision.
-fpcc-struct-
return
Returns all struct and union values in memory,
rather than in registers. (Returning values this way is
less efficient, but at least it’s compatible with other
compilers.)
(continued)
42_770191-bk08ch01.indd 53542_770191-bk08ch01.indd 535 8/6/10 9:51 AM8/6/10 9:51 AM