CAUTION
781
Programming Tools and Utilities 29
With GCC (and any other C compiler), the preprocessing stage handles constructs such as the
#include
as well as #define macros. Once these are handled, normal processing
begins.
GCC relies on file extensions to determine what kind of source code file it is??”that is, in which
programming language the source code is written. Table 29-1 lists the most common extensions
and how GCC interprets them.
TABLE 29-1
GCC??™s Filenaming Conventions
Extension Type
.a, .so Compiled library code
.c C language source code
.C, .cc C++ language source code (these may also have .cpp, .cxx, .CPP,.cp, or .c++ as an
extension)
.i Preprocessed C source code
.ii Preprocessed C++ source code
.m Objective-C source code
.o Compiled object code
.S, .s Assembly language source code
Compiling Multiple Source Code Files
Most non-trivial programs consist of multiple source files, and each source file must be compiled
to object code before the final link step. To do so, pass gcc the name of each source code file it has
to compile. GCC handles the rest. The gcc invocation might resemble the following:
$ gcc file1.c file2.c file3.c -o progname
gcc would create file1.o, file2.o, and file3.o and then link them all together to create
progname.
Pages:
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417