Using the GNU Compiler Collection (GCC)
Total Page:16
File Type:pdf, Size:1020Kb
Using the GNU Compiler Collection (GCC) Using the GNU Compiler Collection by Richard M. Stallman and the GCC Developer Community For GCC Version 4.0.2 Published by: GNU Press Website: www.gnupress.org a division of the General: [email protected] Free Software Foundation Orders: [email protected] 59 Temple Place Suite 330 Tel 617-542-5942 Boston, MA 02111-1307 USA Fax 617-542-2652 Last printed October 2003 for GCC 3.3.1. Printed copies are available for $45 each. Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being “GNU General Public License” and “Funding Free Software”, the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled “GNU Free Documentation License”. (a) The FSF’s Front-Cover Text is: A GNU Manual (b) The FSF’s Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents Introduction ...................................... 1 1 Programming Languages Supported by GCC ............ 3 2 Language Standards Supported by GCC ............... 5 3 GCC Command Options .......................... 7 4 C Implementation-defined behavior ................. 195 5 Extensions to the C Language Family ................ 203 6 Extensions to the C++ Language ................... 339 7 GNU Objective-C runtime features.................. 349 8 Binary Compatibility ........................... 355 9 gcov—a Test Coverage Program ................... 359 10 Known Causes of Trouble with GCC ................ 367 11 Reporting Bugs ............................... 385 12 How To Get Help with GCC ...................... 387 13 Contributing to GCC Development ................. 389 Funding Free Software ............................. 391 The GNU Project and GNU/Linux..................... 393 GNU GENERAL PUBLIC LICENSE ................... 395 GNU Free Documentation License ..................... 401 Contributors to GCC .............................. 409 Option Index.................................... 423 Keyword Index .................................. 435 ii Using the GNU Compiler Collection (GCC) iii Table of Contents Introduction .................................. 1 1 Programming Languages Supported by GCC ......................................... 3 2 Language Standards Supported by GCC .... 5 3 GCC Command Options ................... 7 3.1 Option Summary ............................................ 7 3.2 Options Controlling the Kind of Output ..................... 17 3.3 Compiling C++ Programs ................................... 20 3.4 Options Controlling C Dialect ............................... 20 3.5 Options Controlling C++ Dialect............................. 24 3.6 Options Controlling Objective-C and Objective-C++ Dialects .. 31 3.7 Options to Control Diagnostic Messages Formatting........... 34 3.8 Options to Request or Suppress Warnings .................... 35 3.9 Options for Debugging Your Program or GCC ................ 49 3.10 Options That Control Optimization ........................ 61 3.11 Options Controlling the Preprocessor ....................... 88 3.12 Passing Options to the Assembler .......................... 97 3.13 Options for Linking ....................................... 97 3.14 Options for Directory Search .............................. 100 3.15 Specifying subprocesses and the switches to pass to them.... 102 3.16 Specifying Target Machine and Compiler Version ........... 108 3.17 Hardware Models and Configurations ...................... 109 3.17.1 ARC Options ....................................... 109 3.17.2 ARM Options ....................................... 109 3.17.3 AVR Options........................................ 113 3.17.4 Blackfin Options..................................... 114 3.17.5 CRIS Options ....................................... 115 3.17.6 Darwin Options ..................................... 117 3.17.7 DEC Alpha Options ................................. 121 3.17.8 DEC Alpha/VMS Options ........................... 125 3.17.9 FRV Options ........................................ 125 3.17.10 H8/300 Options .................................... 129 3.17.11 HPPA Options ..................................... 129 3.17.12 Intel 386 and AMD x86-64 Options .................. 132 3.17.13 IA-64 Options ...................................... 139 3.17.14 M32R/D Options ................................... 141 3.17.15 M680x0 Options .................................... 143 3.17.16 M68hc1x Options................................... 145 3.17.17 MCore Options ..................................... 146 iv Using the GNU Compiler Collection (GCC) 3.17.18 MIPS Options...................................... 147 3.17.19 MMIX Options ..................................... 152 3.17.20 MN10300 Options .................................. 154 3.17.21 NS32K Options .................................... 154 3.17.22 PDP-11 Options.................................... 156 3.17.23 PowerPC Options .................................. 157 3.17.24 IBM RS/6000 and PowerPC Options ................. 157 3.17.25 S/390 and zSeries Options........................... 167 3.17.26 SH Options ........................................ 169 3.17.27 SPARC Options .................................... 171 3.17.28 Options for System V ............................... 175 3.17.29 TMS320C3x/C4x Options ........................... 175 3.17.30 V850 Options ...................................... 177 3.17.31 VAX Options ...................................... 178 3.17.32 x86-64 Options ..................................... 178 3.17.33 Xstormy16 Options ................................. 178 3.17.34 Xtensa Options..................................... 179 3.17.35 zSeries Options ..................................... 180 3.18 Options for Code Generation Conventions.................. 180 3.19 Environment Variables Affecting GCC ..................... 186 3.20 Using Precompiled Headers ............................... 189 3.21 Running Protoize ........................................ 191 4 C Implementation-defined behavior ....... 195 4.1 Translation ............................................... 195 4.2 Environment.............................................. 195 4.3 Identifiers ................................................ 195 4.4 Characters................................................ 196 4.5 Integers .................................................. 196 4.6 Floating point ............................................ 197 4.7 Arrays and pointers ....................................... 198 4.8 Hints ..................................................... 199 4.9 Structures, unions, enumerations, and bit-fields .............. 199 4.10 Qualifiers ................................................ 200 4.11 Declarators .............................................. 200 4.12 Statements .............................................. 200 4.13 Preprocessing directives .................................. 200 4.14 Library functions......................................... 201 4.15 Architecture ............................................. 201 4.16 Locale-specific behavior................................... 201 v 5 Extensions to the C Language Family ..... 203 5.1 Statements and Declarations in Expressions ................. 203 5.2 Locally Declared Labels ................................... 204 5.3 Labels as Values .......................................... 205 5.4 Nested Functions.......................................... 206 5.5 Constructing Function Calls................................ 208 5.6 Referring to a Type with typeof ........................... 209 5.7 Conditionals with Omitted Operands ....................... 210 5.8 Double-Word Integers ..................................... 211 5.9 Complex Numbers ........................................ 211 5.10 Hex Floats............................................... 212 5.11 Arrays of Length Zero .................................... 212 5.12 Structures With No Members ............................. 213 5.13 Arrays of Variable Length ................................ 213 5.14 Macros with a Variable Number of Arguments. ............. 214 5.15 Slightly Looser Rules for Escaped Newlines................. 215 5.16 Non-Lvalue Arrays May Have Subscripts ................... 215 5.17 Arithmetic on void- and Function-Pointers................. 216 5.18 Non-Constant Initializers ................................. 216 5.19 Compound Literals ....................................... 216 5.20 Designated Initializers .................................... 217 5.21 Case Ranges ............................................. 218 5.22 Cast to a Union Type .................................... 218 5.23 Mixed Declarations and Code ............................. 219 5.24 Declaring Attributes of Functions.......................... 219 5.25 Attribute Syntax ......................................... 231 5.26 Prototypes and Old-Style Function Definitions.............. 234 5.27 C++ Style Comments ..................................... 234 5.28 Dollar Signs in Identifier Names ........................... 235 5.29 The Character hESCi in Constants.........................