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 Last updated 23 May 2004 for GCC 3.4.6 For GCC Version 3.4.6 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 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 .......................... 9 4 C Implementation-defined behavior ................. 175 5 Extensions to the C Language Family ................ 179 6 Extensions to the C++ Language ................... 301 7 GNU Objective-C runtime features.................. 313 8 Binary Compatibility ........................... 319 9 gcov|a Test Coverage Program ................... 323 10 Known Causes of Trouble with GCC ................ 331 11 Reporting Bugs ............................... 351 12 How To Get Help with GCC ...................... 353 13 Contributing to GCC Development ................. 355 Funding Free Software ............................. 357 The GNU Project and GNU/Linux..................... 359 GNU GENERAL PUBLIC LICENSE ................... 361 GNU Free Documentation License ..................... 367 Contributors to GCC .............................. 375 Option Index.................................... 387 Keyword Index .................................. 399 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 ................... 9 3.1 Option Summary .......................................... 9 3.2 Options Controlling the Kind of Output .................... 18 3.3 Compiling C++ Programs ................................. 21 3.4 Options Controlling C Dialect ............................. 21 3.5 Options Controlling C++ Dialect ........................... 25 3.6 Options Controlling Objective-C Dialect.................... 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 ....................... 56 3.11 Options Controlling the Preprocessor ..................... 77 3.12 Passing Options to the Assembler......................... 86 3.13 Options for Linking...................................... 86 3.14 Options for Directory Search ............................. 89 3.15 Specifying subprocesses and the switches to pass to them ... 90 3.16 Specifying Target Machine and Compiler Version .......... 97 3.17 Hardware Models and Configurations ..................... 97 3.17.1 M680x0 Options .................................. 98 3.17.2 M68hc1x Options ................................ 100 3.17.3 VAX Options .................................... 101 3.17.4 SPARC Options.................................. 101 3.17.5 ARM Options.................................... 106 3.17.6 MN10300 Options ................................ 110 3.17.7 M32R/D Options ................................ 110 3.17.8 IBM RS/6000 and PowerPC Options .............. 112 3.17.9 Darwin Options .................................. 121 3.17.10 MIPS Options .................................. 123 3.17.11 Intel 386 and AMD x86-64 Options ............... 127 3.17.12 HPPA Options.................................. 134 3.17.13 Intel 960 Options ............................... 137 3.17.14 DEC Alpha Options............................. 138 3.17.15 DEC Alpha/VMS Options ....................... 142 3.17.16 H8/300 Options................................. 142 3.17.17 SH Options ..................................... 143 iv Using the GNU Compiler Collection (GCC) 3.17.18 Options for System V ........................... 144 3.17.19 TMS320C3x/C4x Options ....................... 144 3.17.20 V850 Options ................................... 146 3.17.21 ARC Options ................................... 148 3.17.22 NS32K Options ................................. 148 3.17.23 AVR Options ................................... 150 3.17.24 MCore Options ................................. 151 3.17.25 IA-64 Options .................................. 151 3.17.26 D30V Options .................................. 153 3.17.27 S/390 and zSeries Options ....................... 154 3.17.28 CRIS Options................................... 155 3.17.29 MMIX Options ................................. 157 3.17.30 PDP-11 Options ................................ 158 3.17.31 Xstormy16 Options ............................. 159 3.17.32 FRV Options ................................... 159 3.17.33 Xtensa Options ................................. 162 3.18 Options for Code Generation Conventions ................ 163 3.19 Environment Variables Affecting GCC ................... 168 3.20 Using Precompiled Headers ............................. 171 3.21 Running Protoize....................................... 172 4 C Implementation-defined behavior ....... 175 4.1 Translation ............................................. 175 4.2 Environment ............................................ 175 4.3 Identifiers ............................................... 175 4.4 Characters .............................................. 175 4.5 Integers................................................. 176 4.6 Floating point........................................... 176 4.7 Arrays and pointers ..................................... 177 4.8 Hints ................................................... 177 4.9 Structures, unions, enumerations, and bit-fields ............ 177 4.10 Qualifiers .............................................. 178 4.11 Preprocessing directives ................................. 178 4.12 Library functions ....................................... 178 4.13 Architecture ........................................... 178 4.14 Locale-specific behavior ................................. 178 5 Extensions to the C Language Family ..... 179 5.1 Statements and Declarations in Expressions ............... 179 5.2 Locally Declared Labels .................................. 180 5.3 Labels as Values......................................... 181 5.4 Nested Functions ........................................ 182 5.5 Constructing Function Calls .............................. 184 5.6 Referring to a Type with typeof ......................... 184 5.7 Generalized Lvalues ..................................... 186 5.8 Conditionals with Omitted Operands ..................... 187 5.9 Double-Word Integers.................................... 187 5.10 Complex Numbers...................................... 187 v 5.11 Hex Floats ............................................. 188 5.12 Arrays of Length Zero .................................. 188 5.13 Structures With No Members ........................... 189 5.14 Arrays of Variable Length ............................... 190 5.15 Macros with a Variable Number of Arguments. ........... 191 5.16 Slightly Looser Rules for Escaped Newlines ............... 191 5.17 Non-Lvalue Arrays May Have Subscripts ................. 192 5.18 Arithmetic on void- and Function-Pointers ............... 192 5.19 Non-Constant Initializers................................ 192 5.20 Compound Literals ..................................... 192 5.21 Designated Initializers .................................. 193 5.22 Case Ranges ........................................... 194 5.23 Cast to a Union Type................................... 195 5.24 Mixed Declarations and Code ........................... 195 5.25 Declaring Attributes of Functions ........................ 195 5.26 Attribute Syntax ....................................... 206 5.27 Prototypes and Old-Style Function Definitions ............ 209 5.28 C++ Style Comments ................................... 209 5.29 Dollar Signs in Identifier Names ......................... 210 5.30 The Character ESC in Constants ........................ 210 h i 5.31 Inquiring on Alignment of Types or Variables............. 210 5.32 Specifying Attributes of Variables........................ 210 5.32.1 M32R/D Variable Attributes ...................... 214 5.32.2 i386 Variable Attributes .......................... 215 5.33 Specifying Attributes of Types .......................... 215 5.33.1 i386 Type Attributes ............................