Using the GNU Compiler Collection
Total Page:16
File Type:pdf, Size:1020Kb
Using the GNU Compiler Collection Richard M. Stallman Last updated 20 April 2002 for GCC 3.2.3 Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. For GCC Version 3.2.3 Published by the Free Software Foundation 59 Temple Place—Suite 330 Boston, MA 02111-1307, USA Last printed April, 1998. Printed copies are available for $50 each. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being “GNU General Public License”, 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 Compile C, C++, Objective-C, Ada, Fortran, or Java ....... 3 2 Language Standards Supported by GCC ............... 5 3 GCC Command Options .......................... 7 4 C Implementation-defined behavior ................. 153 5 Extensions to the C Language Family ................ 157 6 Extensions to the C++ Language ................... 255 7 GNU Objective-C runtime features.................. 267 8 Binary Compatibility ........................... 273 9 gcov—a Test Coverage Program ................... 277 10 Known Causes of Trouble with GCC ................ 283 11 Reporting Bugs ............................... 303 12 How To Get Help with GCC ...................... 309 13 Contributing to GCC Development ................. 311 14 Using GCC on VMS............................ 313 Funding Free Software ............................. 319 The GNU Project and GNU/Linux..................... 321 GNU GENERAL PUBLIC LICENSE ................... 323 GNU Free Documentation License ..................... 331 Contributors to GCC .............................. 339 Option Index.................................... 351 Index ......................................... 361 ii Using the GNU Compiler Collection (GCC) iii Table of Contents Introduction .................................. 1 1 Compile C, C++, Objective-C, Ada, Fortran, or Java ..................................... 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 ................. 16 3.3 Compiling C++ Programs ............................... 19 3.4 Options Controlling C Dialect ........................... 19 3.5 Options Controlling C++ Dialect......................... 24 3.6 Options Controlling Objective-C Dialect ................. 31 3.7 Options to Control Diagnostic Messages Formatting ...... 31 3.8 Options to Request or Suppress Warnings ................ 32 3.9 Options for Debugging Your Program or GCC............ 44 3.10 Options That Control Optimization .................... 51 3.11 Options Controlling the Preprocessor ................... 62 3.12 Passing Options to the Assembler ...................... 69 3.13 Options for Linking ................................... 69 3.14 Options for Directory Search ........................... 72 3.15 Specifying subprocesses and the switches to pass to them ....................................................... 74 3.16 Specifying Target Machine and Compiler Version ........ 80 3.17 Hardware Models and Configurations ................... 81 3.17.1 M680x0 Options .............................. 81 3.17.2 M68hc1x Options............................. 83 3.17.3 VAX Options ................................ 84 3.17.4 SPARC Options .............................. 84 3.17.5 Convex Options .............................. 87 3.17.6 AMD29K Options ............................ 88 3.17.7 ARM Options ................................ 90 3.17.8 MN10200 Options ............................ 94 3.17.9 MN10300 Options ............................ 94 3.17.10 M32R/D Options............................ 95 3.17.11 M88K Options .............................. 96 3.17.12 IBM RS/6000 and PowerPC Options.......... 99 3.17.13 IBM RT Options ........................... 106 3.17.14 MIPS Options.............................. 107 3.17.15 Intel 386 and AMD x86-64 Options .......... 112 3.17.16 HPPA Options ............................. 117 iv Using the GNU Compiler Collection (GCC) 3.17.17 Intel 960 Options ........................... 119 3.17.18 DEC Alpha Options ........................ 120 3.17.19 DEC Alpha/VMS Options .................. 124 3.17.20 Clipper Options ............................ 124 3.17.21 H8/300 Options ............................ 124 3.17.22 SH Options ................................ 125 3.17.23 Options for System V ....................... 126 3.17.24 TMS320C3x/C4x Options................... 126 3.17.25 V850 Options .............................. 128 3.17.26 ARC Options .............................. 129 3.17.27 NS32K Options ............................ 130 3.17.28 AVR Options .............................. 131 3.17.29 MCore Options............................. 132 3.17.30 IA-64 Options .............................. 133 3.17.31 D30V Options.............................. 134 3.17.32 S/390 and zSeries Options .................. 135 3.17.33 CRIS Options .............................. 136 3.17.34 MMIX Options............................. 137 3.17.35 PDP-11 Options............................ 138 3.17.36 Xstormy16 Options ......................... 139 3.17.37 Xtensa Options ............................ 140 3.18 Options for Code Generation Conventions.............. 142 3.19 Environment Variables Affecting GCC ................. 148 3.20 Running Protoize .................................... 150 4 C Implementation-defined behavior ....... 153 4.1 Translation ........................................... 153 4.2 Environment.......................................... 153 4.3 Identifiers ............................................ 153 4.4 Characters............................................ 153 4.5 Integers .............................................. 154 4.6 Floating point ........................................ 154 4.7 Arrays and pointers ................................... 155 4.8 Hints................................................. 155 4.9 Structures, unions, enumerations, and bit-fields .......... 155 4.10 Qualifiers ............................................ 155 4.11 Preprocessing directives .............................. 155 4.12 Library functions..................................... 156 4.13 Architecture ......................................... 156 4.14 Locale-specific behavior............................... 156 v 5 Extensions to the C Language Family ..... 157 5.1 Statements and Declarations in Expressions ............. 157 5.2 Locally Declared Labels ............................... 158 5.3 Labels as Values ...................................... 159 5.4 Nested Functions...................................... 160 5.5 Constructing Function Calls ........................... 161 5.6 Referring to a Type with typeof ....................... 162 5.7 Generalized Lvalues ................................... 164 5.8 Conditionals with Omitted Operands ................... 165 5.9 Double-Word Integers ................................. 165 5.10 Complex Numbers ................................... 165 5.11 Hex Floats .......................................... 166 5.12 Arrays of Length Zero ................................ 166 5.13 Arrays of Variable Length ............................ 168 5.14 Macros with a Variable Number of Arguments. ......... 169 5.15 Slightly Looser Rules for Escaped Newlines ............ 170 5.16 String Literals with Embedded Newlines ............... 170 5.17 Non-Lvalue Arrays May Have Subscripts ............... 170 5.18 Arithmetic on void- and Function-Pointers............. 170 5.19 Non-Constant Initializers ............................. 171 5.20 Compound Literals ................................... 171 5.21 Designated Initializers ................................ 172 5.22 Case Ranges ......................................... 173 5.23 Cast to a Union Type ................................ 173 5.24 Mixed Declarations and Code ......................... 174 5.25 Declaring Attributes of Functions ..................... 174 5.26 Attribute Syntax ..................................... 182 5.27 Prototypes and Old-Style Function Definitions ......... 185 5.28 C++ Style Comments ................................. 186 5.29 Dollar Signs in Identifier Names ....................... 186 5.30 The Character hESCi in Constants...................... 186 5.31 Inquiring on Alignment of Types or Variables .......... 186 5.32 Specifying Attributes of Variables ..................... 187 5.33 Specifying Attributes of Types ........................ 191 5.34 An Inline Function is As Fast As a Macro .............. 194 5.35 Assembler Instructions with C Expression Operands .... 195 5.35.1 i386 floating point asm operands.............. 200 5.36 Constraints for asm Operands ......................... 201 5.36.1 Simple Constraints .......................... 201 5.36.2 Multiple Alternative Constraints.............. 203 5.36.3 Constraint Modifier Characters ............... 203 5.36.4 Constraints for Particular Machines