Supported Languages
When using the cc command, which supports more than one language, the language is determined by either the filename suffix or by explicitly specifying the language using the -x option. Table 4-2 lists some of the more commonly used filename suffixes and -x arguments supported by Apple’s version of GCC.
|
File suffix |
Language |
-x argument |
|
.c |
C source code to be preprocessed and compiled |
c |
|
.C, .cc, .cxx, .cpp |
C++ source code to be preprocessed and compiled |
c++ |
|
.h |
C header that should neither be compiled nor linked |
c-header |
|
.i |
C source code that should be compiled but not preprocessed |
cpp-output |
|
.ii |
Objective-C++ or C++ source code that should be compiled but not preprocessed |
c++-cpp-output |
|
.m |
Objective-C source code |
objective-c |
|
.M, .mm |
Mixed Objective-C++ and Objective-C source code |
objective-c++ |
|
.s |
Assembler source that should be assembled but not preprocessed |
assembler |
|
.S |
Assembler source to be preprocessed and assembled |
assembler-with-cpp |
Although the HFS+ filesystem is case-insensitive, the cc compile driver recognizes the uppercase C in a source file. For example, cc foo.C invokes cc’s C++ compiler because the file extension is an uppercase C, which denotes a C++ source file. (To cc, it’s just a command-line argument.) So, even though HFS+ will find the same file whether you type cc foo.c or cc foo.C, what you enter on the command line makes all the difference in the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access