|
|
1.1.1.7 ! root 1: This is Info file gcc.info, produced by Makeinfo-1.55 from the input 1.1 root 2: file gcc.texi. 3: 4: This file documents the use and the internals of the GNU compiler. 5: 1.1.1.5 root 6: Published by the Free Software Foundation 675 Massachusetts Avenue 7: Cambridge, MA 02139 USA 8: 1.1.1.7 ! root 9: Copyright (C) 1988, 1989, 1992, 1993, 1994 Free Software Foundation, ! 10: Inc. 1.1 root 11: 1.1.1.3 root 12: Permission is granted to make and distribute verbatim copies of this 13: manual provided the copyright notice and this permission notice are 14: preserved on all copies. 1.1 root 15: 16: Permission is granted to copy and distribute modified versions of 17: this manual under the conditions for verbatim copying, provided also 1.1.1.7 ! root 18: that the sections entitled "GNU General Public License," "Funding for ! 19: Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are ! 20: included exactly as in the original, and provided that the entire ! 21: resulting derived work is distributed under the terms of a permission ! 22: notice identical to this one. 1.1 root 23: 24: Permission is granted to copy and distribute translations of this 25: manual into another language, under the above conditions for modified 1.1.1.3 root 26: versions, except that the sections entitled "GNU General Public 1.1.1.7 ! root 27: License," "Funding for Free Software," and "Protect Your Freedom--Fight ! 28: `Look And Feel'", and this permission notice, may be included in ! 29: translations approved by the Free Software Foundation instead of in the ! 30: original English. ! 31: ! 32: ! 33: File: gcc.info, Node: Option Summary, Next: Overall Options, Up: Invoking GCC ! 34: ! 35: Option Summary ! 36: ============== ! 37: ! 38: Here is a summary of all the options, grouped by type. Explanations ! 39: are in the following sections. ! 40: ! 41: *Overall Options* ! 42: *Note Options Controlling the Kind of Output: Overall Options. ! 43: -c -S -E -o FILE -pipe -v -x LANGUAGE ! 44: ! 45: *C Language Options* ! 46: *Note Options Controlling C Dialect: C Dialect Options. ! 47: -ansi -fallow-single-precision -fcond-mismatch -fno-asm ! 48: -fno-builtin -fsigned-bitfields -fsigned-char ! 49: -funsigned-bitfields -funsigned-char -fwritable-strings ! 50: -traditional -traditional-cpp -trigraphs ! 51: ! 52: *C++ Language Options* ! 53: *Note Options Controlling C++ Dialect: C++ Dialect Options. ! 54: -fall-virtual -fdollars-in-identifiers -felide-constructors ! 55: -fenum-int-equiv -fexternal-templates -fhandle-signatures ! 56: -fmemoize-lookups -fno-default-inline -fno-strict-prototype ! 57: -fnonnull-objects -fthis-is-variable -nostdinc++ ! 58: -traditional +eN ! 59: ! 60: *Warning Options* ! 61: *Note Options to Request or Suppress Warnings: Warning Options. ! 62: -fsyntax-only -pedantic -pedantic-errors ! 63: -w -W -Wall -Waggregate-return -Wbad-function-cast ! 64: -Wcast-align -Wcast-qual -Wchar-subscript -Wcomment ! 65: -Wconversion -Wenum-clash -Werror -Wformat ! 66: -Wid-clash-LEN -Wimplicit -Wimport -Winline ! 67: -Wlarger-than-LEN -Wmissing-declarations ! 68: -Wmissing-prototypes -Wnested-externs ! 69: -Wno-import -Woverloaded-virtual -Wparentheses ! 70: -Wpointer-arith -Wredundant-decls -Wreorder -Wreturn-type -Wshadow ! 71: -Wstrict-prototypes -Wswitch -Wsynth -Wtemplate-debugging ! 72: -Wtraditional -Wtrigraphs -Wuninitialized -Wunused ! 73: -Wwrite-strings ! 74: ! 75: *Debugging Options* ! 76: *Note Options for Debugging Your Program or GCC: Debugging Options. ! 77: -a -dLETTERS -fpretend-float ! 78: -g -gLEVEL -gcoff -gdwarf -gdwarf+ ! 79: -ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ ! 80: -p -pg -print-file-name=LIBRARY -print-libgcc-file-name ! 81: -print-prog-name=PROGRAM -save-temps ! 82: ! 83: *Optimization Options* ! 84: *Note Options that Control Optimization: Optimize Options. ! 85: -fcaller-saves -fcse-follow-jumps -fcse-skip-blocks ! 86: -fdelayed-branch -fexpensive-optimizations ! 87: -ffast-math -ffloat-store -fforce-addr -fforce-mem ! 88: -finline-functions -fkeep-inline-functions ! 89: -fno-default-inline -fno-defer-pop -fno-function-cse ! 90: -fno-inline -fno-peephole -fomit-frame-pointer ! 91: -frerun-cse-after-loop -fschedule-insns ! 92: -fschedule-insns2 -fstrength-reduce -fthread-jumps ! 93: -funroll-all-loops -funroll-loops ! 94: -O -O0 -O1 -O2 -O3 ! 95: ! 96: *Preprocessor Options* ! 97: *Note Options Controlling the Preprocessor: Preprocessor Options. ! 98: -AQUESTION(ANSWER) -C -dD -dM -dN ! 99: -DMACRO[=DEFN] -E -H ! 100: -idirafter DIR ! 101: -include FILE -imacros FILE ! 102: -iprefix FILE -iwithprefix DIR ! 103: -iwithprefixbefore DIR -isystem DIR ! 104: -M -MD -MM -MMD -MG -nostdinc -P -trigraphs ! 105: -undef -UMACRO -Wp,OPTION ! 106: ! 107: *Assembler Option* ! 108: *Note Passing Options to the Assembler: Assembler Options. ! 109: -Wa,OPTION ! 110: ! 111: *Linker Options* ! 112: *Note Options for Linking: Link Options. ! 113: OBJECT-FILE-NAME ! 114: -lLIBRARY -nostartfiles -nostdlib ! 115: -s -static -shared -symbolic ! 116: -Wl,OPTION -Xlinker OPTION ! 117: -u SYMBOL ! 118: ! 119: *Directory Options* ! 120: *Note Options for Directory Search: Directory Options. ! 121: -BPREFIX -IDIR -I- -LDIR ! 122: ! 123: *Target Options* ! 124: *Note Target Options::. ! 125: -b MACHINE -V VERSION ! 126: ! 127: *Machine Dependent Options* ! 128: *Note Hardware Models and Configurations: Submodel Options. ! 129: *M680x0 Options* ! 130: -m68000 -m68020 -m68020-40 -m68030 -m68040 -m68881 ! 131: -mbitfield -mc68000 -mc68020 -mfpa -mnobitfield ! 132: -mrtd -mshort -msoft-float ! 133: ! 134: *VAX Options* ! 135: -mg -mgnu -munix ! 136: ! 137: *SPARC Options* ! 138: -mapp-regs -mcypress -mepilogue -mflat -mfpu -mhard-float ! 139: -mhard-quad-float -mno-app-regs -mno-flat -mno-fpu ! 140: -mno-epilogue -mno-unaligned-doubles ! 141: -msoft-float -msoft-quad-float ! 142: -msparclite -msupersparc -munaligned-doubles -mv8 ! 143: ! 144: SPARC V9 compilers support the following options ! 145: in addition to the above: ! 146: ! 147: -mmedlow -mmedany ! 148: -mint32 -mint64 -mlong32 -mlong64 ! 149: -mno-stack-bias -mstack-bias ! 150: ! 151: *Convex Options* ! 152: -mc1 -mc2 -mc32 -mc34 -mc38 ! 153: -margcount -mnoargcount ! 154: -mlong32 -mlong64 ! 155: -mvolatile-cache -mvolatile-nocache ! 156: ! 157: *AMD29K Options* ! 158: -m29000 -m29050 -mbw -mnbw -mdw -mndw ! 159: -mlarge -mnormal -msmall ! 160: -mkernel-registers -mno-reuse-arg-regs ! 161: -mno-stack-check -mno-storem-bug ! 162: -mreuse-arg-regs -msoft-float -mstack-check ! 163: -mstorem-bug -muser-registers ! 164: ! 165: *ARM Options* ! 166: -mapcs -m2 -m3 -m6 -mbsd -mxopen -mno-symrename ! 167: ! 168: *M88K Options* ! 169: -m88000 -m88100 -m88110 -mbig-pic ! 170: -mcheck-zero-division -mhandle-large-shift ! 171: -midentify-revision -mno-check-zero-division ! 172: -mno-ocs-debug-info -mno-ocs-frame-position ! 173: -mno-optimize-arg-area -mno-serialize-volatile ! 174: -mno-underscores -mocs-debug-info ! 175: -mocs-frame-position -moptimize-arg-area ! 176: -mserialize-volatile -mshort-data-NUM -msvr3 ! 177: -msvr4 -mtrap-large-shift -muse-div-instruction ! 178: -mversion-03.00 -mwarn-passed-structs ! 179: ! 180: *RS/6000 Options and PowerPC* ! 181: -mcpu=CPU TYPE ! 182: -mpower -mno-power -mpower2 -pno-power2 ! 183: -mpowerpc -mno-powerpc ! 184: -mpowerpc-gpopt -mno-powerpc-gpopt ! 185: -mpowerpc-gfxopt -mno-powerpc-gfxopt ! 186: -mnew-mnemonics -mno-new-mnemonics ! 187: -mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc ! 188: ! 189: *RT Options* ! 190: -mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs ! 191: -mfull-fp-blocks -mhc-struct-return -min-line-mul ! 192: -mminimum-fp-blocks -mnohc-struct-return ! 193: ! 194: *MIPS Options* ! 195: -mabicalls -mcpu=CPU TYPE -membedded-data ! 196: -membedded-pic -mfp32 -mfp64 -mgas -mgp32 -mgp64 ! 197: -mgpopt -mhalf-pic -mhard-float -mint64 -mips1 ! 198: -mips2 -mips3 -mlong64 -mlong-calls -mmemcpy ! 199: -mmips-as -mmips-tfile -mno-abicalls ! 200: -mno-embedded-data -mno-embedded-pic ! 201: -mno-gpopt -mno-long-calls ! 202: -mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats ! 203: -mrnames -msoft-float ! 204: -mstats -G NUM -nocpp ! 205: ! 206: *i386 Options* ! 207: -m486 -mieee-fp -mno-486 -mno-fancy-math-387 ! 208: -mno-fp-ret-in-387 -msoft-float -msvr3-shlib ! 209: -mno-wide-multiply -mreg-alloc=LIST ! 210: ! 211: *HPPA Options* ! 212: -mdisable-fpregs -mdisable-indexing -mjump-in-delay ! 213: -mgas -mlong-calls -mno-disable-fpregs -mno-disable-indexing ! 214: -mno-gas -mno-jump-in-delay ! 215: -mno-long-calls -mno-portable-runtime ! 216: -mpa-risc-1-0 -mpa-risc-1-1 -mportable-runtime ! 217: ! 218: *Intel 960 Options* ! 219: -mCPU TYPE -masm-compat -mclean-linkage ! 220: -mcode-align -mcomplex-addr -mleaf-procedures ! 221: -mic-compat -mic2.0-compat -mic3.0-compat ! 222: -mintel-asm -mno-clean-linkage -mno-code-align ! 223: -mno-complex-addr -mno-leaf-procedures ! 224: -mno-old-align -mno-strict-align -mno-tail-call ! 225: -mnumerics -mold-align -msoft-float -mstrict-align ! 226: -mtail-call ! 227: ! 228: *DEC Alpha Options* ! 229: -mfp-regs -mno-fp-regs -mno-soft-float ! 230: -msoft-float ! 231: ! 232: *Clipper Options* ! 233: -mc300 -mc400 ! 234: ! 235: *H8/300 Options* ! 236: -mrelax -mh ! 237: ! 238: *System V Options* ! 239: -Qy -Qn -YP,PATHS -Ym,DIR ! 240: ! 241: *Code Generation Options* ! 242: *Note Options for Code Generation Conventions: Code Gen Options. ! 243: -fcall-saved-REG -fcall-used-REG ! 244: -ffixed-REG -finhibit-size-directive ! 245: -fno-common -fno-ident -fno-gnu-linker ! 246: -fpcc-struct-return -fpic -fPIC ! 247: -freg-struct-return -fshared-data -fshort-enums ! 248: -fshort-double -fvolatile -fvolatile-global ! 249: -fverbose-asm +e0 +e1 ! 250: ! 251: * Menu: ! 252: ! 253: * Overall Options:: Controlling the kind of output: ! 254: an executable, object files, assembler files, ! 255: or preprocessed source. ! 256: * C Dialect Options:: Controlling the variant of C language compiled. ! 257: * C++ Dialect Options:: Variations on C++. ! 258: * Warning Options:: How picky should the compiler be? ! 259: * Debugging Options:: Symbol tables, measurements, and debugging dumps. ! 260: * Optimize Options:: How much optimization? ! 261: * Preprocessor Options:: Controlling header files and macro definitions. ! 262: Also, getting dependency information for Make. ! 263: * Assembler Options:: Passing options to the assembler. ! 264: * Link Options:: Specifying libraries and so on. ! 265: * Directory Options:: Where to find header files and libraries. ! 266: Where to find the compiler executable files. ! 267: * Target Options:: Running a cross-compiler, or an old version of GNU CC. ! 268: ! 269: ! 270: File: gcc.info, Node: Overall Options, Next: Invoking G++, Prev: Option Summary, Up: Invoking GCC ! 271: ! 272: Options Controlling the Kind of Output ! 273: ====================================== ! 274: ! 275: Compilation can involve up to four stages: preprocessing, compilation ! 276: proper, assembly and linking, always in that order. The first three ! 277: stages apply to an individual source file, and end by producing an ! 278: object file; linking combines all the object files (those newly ! 279: compiled, and those specified as input) into an executable file. ! 280: ! 281: For any given input file, the file name suffix determines what kind ! 282: of compilation is done: ! 283: ! 284: `FILE.c' ! 285: C source code which must be preprocessed. ! 286: ! 287: `FILE.i' ! 288: C source code which should not be preprocessed. ! 289: ! 290: `FILE.ii' ! 291: C++ source code which should not be preprocessed. ! 292: ! 293: `FILE.m' ! 294: Objective-C source code. Note that you must link with the library ! 295: `libobjc.a' to make an Objective-C program work. ! 296: ! 297: `FILE.h' ! 298: C header file (not to be compiled or linked). ! 299: ! 300: `FILE.cc' ! 301: `FILE.cxx' ! 302: `FILE.cpp' ! 303: `FILE.C' ! 304: C++ source code which must be preprocessed. Note that in `.cxx', ! 305: the last two letters must both be literally `x'. Likewise, `.C' ! 306: refers to a literal capital C. ! 307: ! 308: `FILE.s' ! 309: Assembler code. ! 310: ! 311: `FILE.S' ! 312: Assembler code which must be preprocessed. ! 313: ! 314: `OTHER' ! 315: An object file to be fed straight into linking. Any file name ! 316: with no recognized suffix is treated this way. ! 317: ! 318: You can specify the input language explicitly with the `-x' option: ! 319: ! 320: `-x LANGUAGE' ! 321: Specify explicitly the LANGUAGE for the following input files ! 322: (rather than letting the compiler choose a default based on the ! 323: file name suffix). This option applies to all following input ! 324: files until the next `-x' option. Possible values for LANGUAGE ! 325: are: ! 326: c objective-c c++ ! 327: c-header cpp-output c++-cpp-output ! 328: assembler assembler-with-cpp ! 329: ! 330: `-x none' ! 331: Turn off any specification of a language, so that subsequent files ! 332: are handled according to their file name suffixes (as they are if ! 333: `-x' has not been used at all). ! 334: ! 335: If you only want some of the stages of compilation, you can use `-x' ! 336: (or filename suffixes) to tell `gcc' where to start, and one of the ! 337: options `-c', `-S', or `-E' to say where `gcc' is to stop. Note that ! 338: some combinations (for example, `-x cpp-output -E' instruct `gcc' to do ! 339: nothing at all. ! 340: ! 341: `-c' ! 342: Compile or assemble the source files, but do not link. The linking ! 343: stage simply is not done. The ultimate output is in the form of an ! 344: object file for each source file. ! 345: ! 346: By default, the object file name for a source file is made by ! 347: replacing the suffix `.c', `.i', `.s', etc., with `.o'. ! 348: ! 349: Unrecognized input files, not requiring compilation or assembly, ! 350: are ignored. ! 351: ! 352: `-S' ! 353: Stop after the stage of compilation proper; do not assemble. The ! 354: output is in the form of an assembler code file for each ! 355: non-assembler input file specified. ! 356: ! 357: By default, the assembler file name for a source file is made by ! 358: replacing the suffix `.c', `.i', etc., with `.s'. ! 359: ! 360: Input files that don't require compilation are ignored. ! 361: ! 362: `-E' ! 363: Stop after the preprocessing stage; do not run the compiler ! 364: proper. The output is in the form of preprocessed source code, ! 365: which is sent to the standard output. ! 366: ! 367: Input files which don't require preprocessing are ignored. ! 368: ! 369: `-o FILE' ! 370: Place output in file FILE. This applies regardless to whatever ! 371: sort of output is being produced, whether it be an executable file, ! 372: an object file, an assembler file or preprocessed C code. ! 373: ! 374: Since only one output file can be specified, it does not make ! 375: sense to use `-o' when compiling more than one input file, unless ! 376: you are producing an executable file as output. ! 377: ! 378: If `-o' is not specified, the default is to put an executable file ! 379: in `a.out', the object file for `SOURCE.SUFFIX' in `SOURCE.o', its ! 380: assembler file in `SOURCE.s', and all preprocessed C source on ! 381: standard output. ! 382: ! 383: `-v' ! 384: Print (on standard error output) the commands executed to run the ! 385: stages of compilation. Also print the version number of the ! 386: compiler driver program and of the preprocessor and the compiler ! 387: proper. ! 388: ! 389: `-pipe' ! 390: Use pipes rather than temporary files for communication between the ! 391: various stages of compilation. This fails to work on some systems ! 392: where the assembler is unable to read from a pipe; but the GNU ! 393: assembler has no trouble. 1.1.1.4 root 394: 395: 1.1.1.5 root 396: File: gcc.info, Node: Invoking G++, Next: C Dialect Options, Prev: Overall Options, Up: Invoking GCC 397: 398: Compiling C++ Programs 399: ====================== 400: 401: C++ source files conventionally use one of the suffixes `.C', `.cc', 1.1.1.7 ! root 402: `cpp', or `.cxx'; preprocessed C++ files use the suffix `.ii'. GNU CC 1.1.1.5 root 403: recognizes files with these names and compiles them as C++ programs 404: even if you call the compiler the same way as for compiling C programs 405: (usually with the name `gcc'). 406: 407: However, C++ programs often require class libraries as well as a 408: compiler that understands the C++ language--and under some 409: circumstances, you might want to compile programs from standard input, 410: or otherwise without a suffix that flags them as C++ programs. `g++' 1.1.1.7 ! root 411: is a program that calls GNU CC with the default language set to C++, ! 412: and automatically specifies linking against the GNU class library 1.1.1.5 root 413: libg++. (1) On many systems, the script `g++' is also installed with 414: the name `c++'. 415: 416: When you compile C++ programs, you may specify many of the same 417: command-line options that you use for compiling programs in any 418: language; or command-line options meaningful for C and related 419: languages; or options that are meaningful only for C++ programs. *Note 420: Options Controlling C Dialect: C Dialect Options, for explanations of 421: options for languages related to C. *Note Options Controlling C++ 422: Dialect: C++ Dialect Options, for explanations of options that are 423: meaningful only for C++ programs. 424: 425: ---------- Footnotes ---------- 426: 427: (1) Prior to release 2 of the compiler, there was a separate `g++' 428: compiler. That version was based on GNU CC, but not integrated with 429: it. Versions of `g++' with a `1.XX' version number--for example, `g++' 430: version 1.37 or 1.42--are much less reliable than the versions 431: integrated with GCC 2. Moreover, combining G++ `1.XX' with a version 2 432: GCC will simply not work. 433: 434: 435: File: gcc.info, Node: C Dialect Options, Next: C++ Dialect Options, Prev: Invoking G++, Up: Invoking GCC 1.1.1.4 root 436: 1.1.1.5 root 437: Options Controlling C Dialect 438: ============================= 1.1.1.4 root 439: 1.1.1.5 root 440: The following options control the dialect of C (or languages derived 441: from C, such as C++ and Objective C) that the compiler accepts: 1.1.1.4 root 442: 443: `-ansi' 444: Support all ANSI standard C programs. 445: 446: This turns off certain features of GNU C that are incompatible 447: with ANSI C, such as the `asm', `inline' and `typeof' keywords, and 448: predefined macros such as `unix' and `vax' that identify the type 449: of system you are using. It also enables the undesirable and 450: rarely used ANSI trigraph feature, and disallows `$' as part of 451: identifiers. 452: 453: The alternate keywords `__asm__', `__extension__', `__inline__' 454: and `__typeof__' continue to work despite `-ansi'. You would not 1.1.1.7 ! root 455: want to use them in an ANSI C program, of course, but it is useful ! 456: to put them in header files that might be included in compilations 1.1.1.4 root 457: done with `-ansi'. Alternate predefined macros such as `__unix__' 458: and `__vax__' are also available, with or without `-ansi'. 459: 460: The `-ansi' option does not cause non-ANSI programs to be rejected 461: gratuitously. For that, `-pedantic' is required in addition to 462: `-ansi'. *Note Warning Options::. 463: 464: The macro `__STRICT_ANSI__' is predefined when the `-ansi' option 465: is used. Some header files may notice this macro and refrain from 466: declaring certain functions or defining certain macros that the 467: ANSI standard doesn't call for; this is to avoid interfering with 468: any programs that might use these names for other things. 469: 470: The functions `alloca', `abort', `exit', and `_exit' are not 471: builtin functions when `-ansi' is used. 472: 473: `-fno-asm' 474: Do not recognize `asm', `inline' or `typeof' as a keyword. These 1.1.1.5 root 475: words may then be used as identifiers. You can use the keywords 476: `__asm__', `__inline__' and `__typeof__' instead. `-ansi' implies 477: `-fno-asm'. 1.1.1.4 root 478: 479: `-fno-builtin' 1.1.1.6 root 480: Don't recognize builtin functions that do not begin with two 1.1.1.5 root 481: leading underscores. Currently, the functions affected include 482: `abort', `abs', `alloca', `cos', `exit', `fabs', `ffs', `labs', 1.1.1.4 root 483: `memcmp', `memcpy', `sin', `sqrt', `strcmp', `strcpy', and 484: `strlen'. 485: 1.1.1.6 root 486: GCC normally generates special code to handle certain builtin 487: functions more efficiently; for instance, calls to `alloca' may 488: become single instructions that adjust the stack directly, and 489: calls to `memcpy' may become inline copy loops. The resulting 490: code is often both smaller and faster, but since the function 491: calls no longer appear as such, you cannot set a breakpoint on 492: those calls, nor can you change the behavior of the functions by 493: linking with a different library. 494: 1.1.1.5 root 495: The `-ansi' option prevents `alloca' and `ffs' from being builtin 496: functions, since these functions do not have an ANSI standard 497: meaning. 1.1.1.4 root 498: 499: `-trigraphs' 500: Support ANSI C trigraphs. You don't want to know about this 501: brain-damage. The `-ansi' option implies `-trigraphs'. 502: 503: `-traditional' 504: Attempt to support some aspects of traditional C compilers. 505: Specifically: 506: 507: * All `extern' declarations take effect globally even if they 508: are written inside of a function definition. This includes 509: implicit declarations of functions. 510: 1.1.1.5 root 511: * The newer keywords `typeof', `inline', `signed', `const' and 1.1.1.4 root 512: `volatile' are not recognized. (You can still use the 513: alternative keywords such as `__typeof__', `__inline__', and 514: so on.) 515: 516: * Comparisons between pointers and integers are always allowed. 517: 518: * Integer types `unsigned short' and `unsigned char' promote to 519: `unsigned int'. 520: 521: * Out-of-range floating point literals are not an error. 522: 1.1.1.5 root 523: * Certain constructs which ANSI regards as a single invalid 524: preprocessing number, such as `0xe-0xd', are treated as 525: expressions instead. 526: 1.1.1.4 root 527: * String "constants" are not necessarily constant; they are 528: stored in writable space, and identical looking constants are 529: allocated separately. (This is the same as the effect of 530: `-fwritable-strings'.) 531: 532: * All automatic variables not declared `register' are preserved 533: by `longjmp'. Ordinarily, GNU C follows ANSI C: automatic 534: variables not declared `volatile' may be clobbered. 535: 1.1.1.5 root 536: * The character escape sequences `\x' and `\a' evaluate as the 537: literal characters `x' and `a' respectively. Without 538: `-traditional', `\x' is a prefix for the hexadecimal 539: representation of a character, and `\a' produces a bell. 540: 541: * In C++ programs, assignment to `this' is permitted with 542: `-traditional'. (The option `-fthis-is-variable' also has 543: this effect.) 1.1.1.4 root 544: 545: You may wish to use `-fno-builtin' as well as `-traditional' if 546: your program uses names that are normally GNU C builtin functions 547: for other purposes of its own. 548: 1.1.1.7 ! root 549: You cannot use `-traditional' if you include any header files that ! 550: rely on ANSI C features. Some vendors are starting to ship ! 551: systems with ANSI C header files and you cannot use `-traditional' ! 552: on such systems to compile files that include any system headers. ! 553: ! 554: `' ! 555: In the preprocessor, comments convert to nothing at all, rather ! 556: than to a space. This allows traditional token concatenation. ! 557: ! 558: `' ! 559: In preprocessor directive, the `#' symbol must appear as the first ! 560: character of a line. ! 561: ! 562: `' ! 563: In the preprocessor, macro arguments are recognized within string ! 564: constants in a macro definition (and their values are stringified, ! 565: though without additional quote marks, when they appear in such a ! 566: context). The preprocessor always considers a string constant to ! 567: end at a newline. ! 568: ! 569: `' ! 570: The predefined macro `__STDC__' is not defined when you use ! 571: `-traditional', but `__GNUC__' is (since the GNU extensions which ! 572: `__GNUC__' indicates are not affected by `-traditional'). If you ! 573: need to write header files that work differently depending on ! 574: whether `-traditional' is in use, by testing both of these ! 575: predefined macros you can distinguish four situations: GNU C, ! 576: traditional GNU C, other ANSI C compilers, and other old C ! 577: compilers. *Note Standard Predefined Macros: (cpp.info)Standard ! 578: Predefined, for more discussion of these and other predefined ! 579: macros. ! 580: ! 581: `' ! 582: The preprocessor considers a string constant to end at a newline ! 583: (unless the newline is escaped with `\'). (Without `-traditional', ! 584: string constants can contain the newline character as typed.) ! 585: 1.1.1.4 root 586: `-traditional-cpp' 587: Attempt to support some aspects of traditional C preprocessors. 1.1.1.7 ! root 588: This includes the last five items in the table immediately above, 1.1.1.4 root 589: but none of the other effects of `-traditional'. 590: 591: `-fcond-mismatch' 592: Allow conditional expressions with mismatched types in the second 593: and third arguments. The value of such an expression is void. 594: 595: `-funsigned-char' 596: Let the type `char' be unsigned, like `unsigned char'. 597: 598: Each kind of machine has a default for what `char' should be. It 599: is either like `unsigned char' by default or like `signed char' by 600: default. 601: 602: Ideally, a portable program should always use `signed char' or 603: `unsigned char' when it depends on the signedness of an object. 604: But many programs have been written to use plain `char' and expect 605: it to be signed, or expect it to be unsigned, depending on the 606: machines they were written for. This option, and its inverse, let 607: you make such a program work with the opposite default. 608: 609: The type `char' is always a distinct type from each of `signed 610: char' or `unsigned char', even though its behavior is always just 611: like one of those two. 612: 613: `-fsigned-char' 614: Let the type `char' be signed, like `signed char'. 615: 616: Note that this is equivalent to `-fno-unsigned-char', which is the 1.1.1.5 root 617: negative form of `-funsigned-char'. Likewise, the option 618: `-fno-signed-char' is equivalent to `-funsigned-char'. 1.1.1.4 root 619: 620: `-fsigned-bitfields' 621: `-funsigned-bitfields' 622: `-fno-signed-bitfields' 623: `-fno-unsigned-bitfields' 624: These options control whether a bitfield is signed or unsigned, 1.1.1.5 root 625: when the declaration does not use either `signed' or `unsigned'. 1.1.1.4 root 626: By default, such a bitfield is signed, because this is consistent: 627: the basic integer types such as `int' are signed types. 628: 629: However, when `-traditional' is used, bitfields are all unsigned 630: no matter what. 631: 632: `-fwritable-strings' 633: Store string constants in the writable data segment and don't 634: uniquize them. This is for compatibility with old programs which 1.1.1.5 root 635: assume they can write into string constants. The option 636: `-traditional' also has this effect. 1.1.1.4 root 637: 638: Writing into string constants is a very bad idea; "constants" 639: should be constant. 1.1 root 640: 1.1.1.6 root 641: `-fallow-single-precision' 642: Do not promote single precision math operations to double 643: precision, even when compiling with `-traditional'. 644: 645: Traditional K&R C promotes all floating point operations to double 646: precision, regardless of the sizes of the operands. On the 647: architecture for which you are compiling, single precision may be 648: faster than double precision. If you must use `-traditional', 649: but want to use single precision operations when the operands are 650: single precision, use this option. This option has no effect 651: when compiling with ANSI or GNU C conventions (the default). 652: 1.1 root 653: 1.1.1.5 root 654: File: gcc.info, Node: C++ Dialect Options, Next: Warning Options, Prev: C Dialect Options, Up: Invoking GCC 655: 656: Options Controlling C++ Dialect 657: =============================== 658: 659: This section describes the command-line options that are only 660: meaningful for C++ programs; but you can also use most of the GNU 661: compiler options regardless of what language your program is in. For 662: example, you might compile a file `firstClass.C' like this: 663: 664: g++ -g -felide-constructors -O -c firstClass.C 665: 666: In this example, only `-felide-constructors' is an option meant only 667: for C++ programs; you can use the other options with any language 668: supported by GNU CC. 669: 670: Here is a list of options that are *only* for compiling C++ programs: 671: 1.1.1.7 ! root 672: `-fno-access-control' ! 673: Turn off all access checking. This switch is mainly useful for ! 674: working around bugs in the access control code. ! 675: 1.1.1.5 root 676: `-fall-virtual' 677: Treat all possible member functions as virtual, implicitly. All 678: member functions (except for constructor functions and `new' or 679: `delete' member operators) are treated as virtual functions of the 680: class where they appear. 681: 682: This does not mean that all calls to these member functions will 683: be made through the internal table of virtual functions. Under 684: some circumstances, the compiler can determine that a call to a 685: given virtual function can be made directly; in these cases the 686: calls are direct in any case. 687: 1.1.1.7 ! root 688: `-fconserve-space' ! 689: Put uninitialized or runtime-initialized global variables into the ! 690: common segment, as C does. This saves space in the executable at ! 691: the cost of not diagnosing duplicate definitions. If your program ! 692: mysteriously crashes after `main()' has completed, you may have an ! 693: object that is being destroyed twice because two definitions were ! 694: merged. ! 695: 1.1.1.5 root 696: `-fdollars-in-identifiers' 697: Accept `$' in identifiers. You can also explicitly prohibit use of 698: `$' with the option `-fno-dollars-in-identifiers'. (GNU C++ 699: allows `$' by default on some target systems but not others.) 700: Traditional C allowed the character `$' to form part of 701: identifiers. However, ANSI C and C++ forbid `$' in identifiers. 702: 703: `-fenum-int-equiv' 704: Permit implicit conversion of `int' to enumeration types. Normally 705: GNU C++ allows conversion of `enum' to `int', but not the other 706: way around. 707: 1.1.1.6 root 708: `-fexternal-templates' 1.1.1.7 ! root 709: Cause template instantiations to obey `#pragma interface' and ! 710: `implementation'; template instances are emitted or not according ! 711: to the location of the template definition. *Note Template ! 712: Instantiation::, for more information. ! 713: ! 714: `-falt-external-templates' ! 715: Similar to -fexternal-templates, but template instances are ! 716: emitted or not according to the place where they are first ! 717: instantiated. *Note Template Instantiation::, for more ! 718: information. ! 719: ! 720: `-fno-implicit-templates' ! 721: Never emit code for templates which are instantiated implicitly ! 722: (i.e. by use); only emit code for explicit instantiations. *Note ! 723: Template Instantiation::, for more information. ! 724: ! 725: `-fhandle-signatures' ! 726: Recognize the `signature' and `sigof' keywords for specifying ! 727: abstract types. The default (`-fno-handle-signatures') is not to ! 728: recognize them. *Note Type Abstraction using Signatures: C++ ! 729: Signatures. ! 730: ! 731: `-fhuge-objects' ! 732: Support virtual function calls for objects that exceed the size ! 733: representable by a `short int'. Users should not use this flag by ! 734: default; if you need to use it, the compiler will tell you so. If ! 735: you compile any of your code with this flag, you must compile ! 736: *all* of your code with this flag (including libg++, if you use ! 737: it). ! 738: ! 739: This flag is not useful when compiling with -fvtable-thunks. ! 740: ! 741: `-fno-implement-inlines' ! 742: To save space, do not emit out-of-line copies of inline functions ! 743: controlled by `#pragma implementation'. This will cause linker ! 744: errors if these functions are not inlined everywhere they are ! 745: called. 1.1.1.6 root 746: 1.1.1.5 root 747: `-fmemoize-lookups' 748: `-fsave-memoized' 749: Use heuristics to compile faster. These heuristics are not 750: enabled by default, since they are only effective for certain 751: input files. Other input files compile more slowly. 752: 753: The first time the compiler must build a call to a member function 754: (or reference to a data member), it must (1) determine whether the 755: class implements member functions of that name; (2) resolve which 756: member function to call (which involves figuring out what sorts of 757: type conversions need to be made); and (3) check the visibility of 758: the member function to the caller. All of this adds up to slower 759: compilation. Normally, the second time a call is made to that 760: member function (or reference to that data member), it must go 761: through the same lengthy process again. This means that code like 762: this: 763: 764: cout << "This " << p << " has " << n << " legs.\n"; 765: 766: makes six passes through all three steps. By using a software 767: cache, a "hit" significantly reduces this cost. Unfortunately, 768: using the cache introduces another layer of mechanisms which must 769: be implemented, and so incurs its own overhead. 770: `-fmemoize-lookups' enables the software cache. 771: 772: Because access privileges (visibility) to members and member 773: functions may differ from one function context to the next, G++ 774: may need to flush the cache. With the `-fmemoize-lookups' flag, 775: the cache is flushed after every function that is compiled. The 776: `-fsave-memoized' flag enables the same software cache, but when 777: the compiler determines that the context of the last function 778: compiled would yield the same access privileges of the next 779: function to compile, it preserves the cache. This is most helpful 780: when defining many member functions for the same class: with the 781: exception of member functions which are friends of other classes, 782: each member function has exactly the same access privileges as 783: every other, and the cache need not be flushed. 784: 785: `-fno-strict-prototype' 786: Treat a function declaration with no arguments, such as `int foo 787: ();', as C would treat it--as saying nothing about the number of 788: arguments or their types. Normally, such a declaration in C++ 789: means that the function `foo' takes no arguments. 790: 1.1.1.7 ! root 791: This option does not work with operator overloading, which places ! 792: constraints on the parameter types. ! 793: 1.1.1.5 root 794: `-fnonnull-objects' 795: Assume that objects reached through references are not null. 796: 797: Normally, GNU C++ makes conservative assumptions about objects 798: reached through references. For example, the compiler must check 799: that `a' is not null in code like the following: 800: 801: obj &a = g (); 802: a.f (2); 803: 804: Checking that references of this sort have non-null values requires 805: extra code, however, and it is unnecessary for many programs. You 806: can use `-fnonnull-objects' to omit the checks for null, if your 807: program doesn't require checking. 808: 1.1.1.7 ! root 809: This checking is currently only done for conversions to virtual ! 810: base classes. ! 811: 1.1.1.5 root 812: `-fthis-is-variable' 813: Permit assignment to `this'. The incorporation of user-defined 814: free store management into C++ has made assignment to `this' an 815: anachronism. Therefore, by default it is invalid to assign to 1.1.1.7 ! root 816: `this' within a class member function; that is, GNU C++ treats ! 817: `this' in a member function of class `X' as a non-lvalue of type ! 818: `X *'. However, for backwards compatibility, you can make it ! 819: valid with `-fthis-is-variable'. ! 820: ! 821: `-fvtable-thunks' ! 822: Use `thunks' to implement the virtual function dispatch table ! 823: (`vtable'). The traditional (cfront-style) approach to ! 824: implementing vtables was to store a pointer to the function and two ! 825: offsets for adjusting the `this' pointer at the call site. Newer ! 826: implementations store a single pointer to a `thunk' function which ! 827: does any necessary adjustment and then calls the target function. ! 828: ! 829: This option also enables a heuristic for controlling emission of ! 830: vtables; if a class has any non-inline virtual functions, the ! 831: vtable will be emitted in the translation unit containing the ! 832: first one of those. 1.1.1.5 root 833: 834: `-nostdinc++' 835: Do not search for header files in the standard directories 836: specific to C++, but do still search the other standard 837: directories. (This option is used when building libg++.) 838: 839: `-traditional' 840: For C++ programs (in addition to the effects that apply to both C 841: and C++), this has the same effect as `-fthis-is-variable'. *Note 842: Options Controlling C Dialect: C Dialect Options. 843: 844: In addition, these optimization, warning, and code generation options 845: have meanings only for C++ programs: 846: 847: `-fno-default-inline' 848: Do not assume `inline' for functions defined inside a class scope. 849: *Note Options That Control Optimization: Optimize Options. 850: 851: `-Wenum-clash' 852: `-Woverloaded-virtual' 853: `-Wtemplate-debugging' 854: Warnings that apply only to C++ programs. *Note Options to 855: Request or Suppress Warnings: Warning Options. 856: 857: `+eN' 858: Control how virtual function definitions are used, in a fashion 859: compatible with `cfront' 1.x. *Note Options for Code Generation 860: Conventions: Code Gen Options. 861: 862: 863: File: gcc.info, Node: Warning Options, Next: Debugging Options, Prev: C++ Dialect Options, Up: Invoking GCC 1.1 root 864: 865: Options to Request or Suppress Warnings 866: ======================================= 867: 1.1.1.3 root 868: Warnings are diagnostic messages that report constructions which are 869: not inherently erroneous but which are risky or suggest there may have 870: been an error. 1.1 root 871: 872: You can request many specific warnings with options beginning `-W', 1.1.1.5 root 873: for example `-Wimplicit' to request warnings on implicit declarations. 1.1.1.3 root 874: Each of these specific warning options also has a negative form 1.1.1.5 root 875: beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'. 1.1 root 876: This manual lists only one of the two forms, whichever is not the 877: default. 878: 879: These options control the amount and kinds of warnings produced by 880: GNU CC: 881: 882: `-fsyntax-only' 1.1.1.5 root 883: Check the code for syntax errors, but don't do anything beyond 884: that. 1.1 root 885: 886: `-w' 887: Inhibit all warning messages. 888: 1.1.1.4 root 889: `-Wno-import' 1.1.1.2 root 890: Inhibit warning messages about the use of `#import'. 891: 1.1 root 892: `-pedantic' 893: Issue all the warnings demanded by strict ANSI standard C; reject 894: all programs that use forbidden extensions. 895: 896: Valid ANSI standard C programs should compile properly with or 1.1.1.5 root 897: without this option (though a rare few will require `-ansi'). 1.1 root 898: However, without this option, certain GNU extensions and 899: traditional C features are supported as well. With this option, 900: they are rejected. 901: 902: `-pedantic' does not cause warning messages for use of the 903: alternate keywords whose names begin and end with `__'. Pedantic 904: warnings are also disabled in the expression that follows 905: `__extension__'. However, only system header files should use 1.1.1.5 root 906: these escape routes; application programs should avoid them. 907: *Note Alternate Keywords::. 1.1 root 908: 1.1.1.3 root 909: This option is not intended to be useful; it exists only to satisfy 910: pedants who would otherwise claim that GNU CC fails to support the 911: ANSI standard. 912: 913: Some users try to use `-pedantic' to check programs for strict ANSI 914: C conformance. They soon find that it does not do quite what they 915: want: it finds some non-ANSI practices, but not all--only those 916: for which ANSI C *requires* a diagnostic. 1.1 root 917: 918: A feature to report any failure to conform to ANSI C might be 919: useful in some instances, but would require considerable 1.1.1.3 root 920: additional work and would be quite different from `-pedantic'. We 921: recommend, rather, that users take advantage of the extensions of 922: GNU C and disregard the limitations of other compilers. Aside 1.1 root 923: from certain supercomputers and obsolete small machines, there is 924: less and less reason ever to use any other C compiler other than 925: for bootstrapping GNU CC. 926: 927: `-pedantic-errors' 928: Like `-pedantic', except that errors are produced rather than 929: warnings. 930: 931: `-W' 932: Print extra warning messages for these events: 933: 1.1.1.3 root 934: * A nonvolatile automatic variable might be changed by a call to 935: `longjmp'. These warnings as well are possible only in 1.1 root 936: optimizing compilation. 937: 938: The compiler sees only the calls to `setjmp'. It cannot know 939: where `longjmp' will be called; in fact, a signal handler 1.1.1.3 root 940: could call it at any point in the code. As a result, you may 941: get a warning even when there is in fact no problem because 942: `longjmp' cannot in fact be called at the place which would 943: cause a problem. 1.1 root 944: 1.1.1.5 root 945: * A function can return either with or without a value. 1.1 root 946: (Falling off the end of the function body is considered 1.1.1.3 root 947: returning without a value.) For example, this function would 948: evoke such a warning: 1.1 root 949: 950: foo (a) 951: { 952: if (a > 0) 953: return a; 954: } 955: 956: * An expression-statement contains no side effects. 957: 1.1.1.7 ! root 958: * An unsigned value is compared against zero with `<' or `<='. 1.1 root 959: 1.1.1.4 root 960: * A comparison like `x<=y<=z' appears; this is equivalent to 961: `(x<=y ? 1 : 0) <= z', which is a different interpretation 962: from that of ordinary mathematical notation. 963: 964: * Storage-class specifiers like `static' are not the first 965: things in a declaration. According to the C Standard, this 966: usage is obsolescent. 967: 1.1.1.5 root 968: * An aggregate has a partly bracketed initializer. For 969: example, the following code would evoke such a warning, 970: because braces are missing around the initializer for `x.h': 1.1.1.4 root 971: 972: struct s { int f, g; }; 973: struct t { struct s h; int i; }; 974: struct t x = { 1, 2, 3 }; 975: 1.1 root 976: `-Wimplicit' 977: Warn whenever a function or parameter is implicitly declared. 978: 979: `-Wreturn-type' 980: Warn whenever a function is defined with a return-type that 981: defaults to `int'. Also warn about any `return' statement with no 982: return-value in a function whose return-type is not `void'. 983: 984: `-Wunused' 1.1.1.7 ! root 985: Warn whenever a variable is unused aside from its declaration, ! 986: whenever a function is declared static but never defined, whenever ! 987: a label is declared but not used, and whenever a statement ! 988: computes a result that is explicitly not used. ! 989: ! 990: To suppress this warning for a local variable or expression, ! 991: simply cast it to void. This will also work for file-scope ! 992: variables, but if you want to mark them used at the point of ! 993: definition, you can use this macro: 1.1.1.4 root 994: 995: #define USE(var) \ 1.1.1.7 ! root 996: static void *const use_##var = (&use_##var, &var, 0) 1.1.1.4 root 997: 998: USE (string); 999: 1.1 root 1000: `-Wswitch' 1001: Warn whenever a `switch' statement has an index of enumeral type 1002: and lacks a `case' for one or more of the named codes of that 1003: enumeration. (The presence of a `default' label prevents this 1004: warning.) `case' labels outside the enumeration range also 1005: provoke warnings when this option is used. 1006: 1007: `-Wcomment' 1008: Warn whenever a comment-start sequence `/*' appears in a comment. 1009: 1010: `-Wtrigraphs' 1011: Warn if any trigraphs are encountered (assuming they are enabled). 1012: 1013: `-Wformat' 1014: Check calls to `printf' and `scanf', etc., to make sure that the 1015: arguments supplied have types appropriate to the format string 1016: specified. 1017: 1018: `-Wchar-subscripts' 1.1.1.3 root 1019: Warn if an array subscript has type `char'. This is a common cause 1020: of error, as programmers often forget that this type is signed on 1021: some machines. 1.1 root 1022: 1023: `-Wuninitialized' 1024: An automatic variable is used without first being initialized. 1025: 1026: These warnings are possible only in optimizing compilation, 1027: because they require data flow information that is computed only 1028: when optimizing. If you don't specify `-O', you simply won't get 1029: these warnings. 1030: 1031: These warnings occur only for variables that are candidates for 1032: register allocation. Therefore, they do not occur for a variable 1033: that is declared `volatile', or whose address is taken, or whose 1.1.1.3 root 1034: size is other than 1, 2, 4 or 8 bytes. Also, they do not occur for 1035: structures, unions or arrays, even when they are in registers. 1.1 root 1036: 1037: Note that there may be no warning about a variable that is used 1038: only to compute a value that itself is never used, because such 1039: computations may be deleted by data flow analysis before the 1040: warnings are printed. 1041: 1042: These warnings are made optional because GNU CC is not smart 1043: enough to see all the reasons why the code might be correct 1044: despite appearing to have an error. Here is one example of how 1045: this can happen: 1046: 1047: { 1048: int x; 1049: switch (y) 1050: { 1051: case 1: x = 1; 1052: break; 1053: case 2: x = 4; 1054: break; 1055: case 3: x = 5; 1056: } 1057: foo (x); 1058: } 1059: 1060: If the value of `y' is always 1, 2 or 3, then `x' is always 1.1.1.3 root 1061: initialized, but GNU CC doesn't know this. Here is another common 1062: case: 1.1 root 1063: 1064: { 1065: int save_y; 1066: if (change_y) save_y = y, y = new_y; 1067: ... 1068: if (change_y) y = save_y; 1069: } 1070: 1071: This has no bug because `save_y' is used only if it is set. 1072: 1.1.1.5 root 1073: Some spurious warnings can be avoided if you declare all the 1.1.1.7 ! root 1074: functions you use that never return as `noreturn'. *Note Function 1.1.1.3 root 1075: Attributes::. 1.1 root 1076: 1.1.1.2 root 1077: `-Wparentheses' 1.1.1.5 root 1078: Warn if parentheses are omitted in certain contexts, such as when 1079: there is an assignment in a context where a truth value is 1080: expected, or when operators are nested whose precedence people 1081: often get confused about. 1082: 1083: `-Wenum-clash' 1084: Warn about conversion between different enumeration types. (C++ 1085: only). 1086: 1087: `-Wtemplate-debugging' 1088: When using templates in a C++ program, warn if debugging is not yet 1089: fully available (C++ only). 1.1.1.2 root 1090: 1.1.1.7 ! root 1091: `-Wreorder (C++ only)' ! 1092: Warn when the order of member initializers given in the code does ! 1093: not match the order in which they must be executed. For instance: ! 1094: ! 1095: struct A { ! 1096: int i; ! 1097: int j; ! 1098: A(): j (0), i (1) { } ! 1099: }; ! 1100: ! 1101: Here the compiler will warn that the member initializers for `i' ! 1102: and `j' will be rearranged to match the declaration order of the ! 1103: members. ! 1104: 1.1 root 1105: `-Wall' 1.1.1.3 root 1106: All of the above `-W' options combined. These are all the options 1107: which pertain to usage that we recommend avoiding and that we 1108: believe is easy to avoid, even in conjunction with macros. 1.1 root 1109: 1110: The remaining `-W...' options are not implied by `-Wall' because 1111: they warn about constructions that we consider reasonable to use, on 1112: occasion, in clean programs. 1113: 1114: `-Wtraditional' 1115: Warn about certain constructs that behave differently in 1116: traditional and ANSI C. 1117: 1118: * Macro arguments occurring within string constants in the 1.1.1.5 root 1119: macro body. These would substitute the argument in 1.1 root 1120: traditional C, but are part of the constant in ANSI C. 1121: 1.1.1.3 root 1122: * A function declared external in one block and then used after 1123: the end of the block. 1.1 root 1124: 1125: * A `switch' statement has an operand of type `long'. 1126: 1127: `-Wshadow' 1128: Warn whenever a local variable shadows another local variable. 1129: 1130: `-Wid-clash-LEN' 1131: Warn whenever two distinct identifiers match in the first LEN 1132: characters. This may help you prepare a program that will compile 1133: with certain obsolete, brain-damaged compilers. 1134: 1.1.1.7 ! root 1135: `-Wlarger-than-LEN' ! 1136: Warn whenever an object of larger than LEN bytes is defined. ! 1137: 1.1 root 1138: `-Wpointer-arith' 1139: Warn about anything that depends on the "size of" a function type 1140: or of `void'. GNU C assigns these types a size of 1, for 1.1.1.3 root 1141: convenience in calculations with `void *' pointers and pointers to 1142: functions. 1.1 root 1143: 1.1.1.7 ! root 1144: `-Wbad-function-cast' ! 1145: Warn whenever a function call is cast to a non-matching type. For ! 1146: example, warn if `int malloc()' is cast to `anything *'. ! 1147: 1.1 root 1148: `-Wcast-qual' 1149: Warn whenever a pointer is cast so as to remove a type qualifier 1150: from the target type. For example, warn if a `const char *' is 1151: cast to an ordinary `char *'. 1152: 1153: `-Wcast-align' 1154: Warn whenever a pointer is cast such that the required alignment 1155: of the target is increased. For example, warn if a `char *' is 1.1.1.3 root 1156: cast to an `int *' on machines where integers can only be accessed 1157: at two- or four-byte boundaries. 1.1 root 1158: 1159: `-Wwrite-strings' 1160: Give string constants the type `const char[LENGTH]' so that 1161: copying the address of one into a non-`const' `char *' pointer 1162: will get a warning. These warnings will help you find at compile 1163: time code that can try to write into a string constant, but only 1164: if you have been very careful about using `const' in declarations 1165: and prototypes. Otherwise, it will just be a nuisance; this is 1166: why we did not make `-Wall' request these warnings. 1167: 1168: `-Wconversion' 1169: Warn if a prototype causes a type conversion that is different 1170: from what would happen to the same argument in the absence of a 1171: prototype. This includes conversions of fixed point to floating 1172: and vice versa, and conversions changing the width or signedness 1173: of a fixed point argument except when the same as the default 1174: promotion. 1175: 1.1.1.5 root 1176: Also, warn if a negative integer constant expression is implicitly 1177: converted to an unsigned type. For example, warn about the 1178: assignment `x = -1' if `x' is unsigned. But do not warn about 1179: explicit casts like `(unsigned) -1'. 1180: 1.1 root 1181: `-Waggregate-return' 1.1.1.3 root 1182: Warn if any functions that return structures or unions are defined 1183: or called. (In languages where you can return an array, this also 1184: elicits a warning.) 1.1 root 1185: 1186: `-Wstrict-prototypes' 1187: Warn if a function is declared or defined without specifying the 1188: argument types. (An old-style function definition is permitted 1.1.1.3 root 1189: without a warning if preceded by a declaration which specifies the 1190: argument types.) 1.1 root 1191: 1192: `-Wmissing-prototypes' 1193: Warn if a global function is defined without a previous prototype 1194: declaration. This warning is issued even if the definition itself 1195: provides a prototype. The aim is to detect global functions that 1196: fail to be declared in header files. 1197: 1.1.1.7 ! root 1198: `-Wmissing-declarations' ! 1199: Warn if a global function is defined without a previous ! 1200: declaration. Do so even if the definition itself provides a ! 1201: prototype. Use this option to detect global functions that are ! 1202: not declared in header files. ! 1203: 1.1 root 1204: `-Wredundant-decls' 1205: Warn if anything is declared more than once in the same scope, 1206: even in cases where multiple declaration is valid and changes 1207: nothing. 1208: 1209: `-Wnested-externs' 1210: Warn if an `extern' declaration is encountered within an function. 1211: 1.1.1.2 root 1212: `-Winline' 1213: Warn if a function can not be inlined, and either it was declared 1214: as inline, or else the `-finline-functions' option was given. 1.1 root 1215: 1.1.1.5 root 1216: `-Woverloaded-virtual' 1217: Warn when a derived class function declaration may be an error in 1218: defining a virtual function (C++ only). In a derived class, the 1219: definitions of virtual functions must match the type signature of a 1220: virtual function declared in the base class. With this option, the 1221: compiler warns when you define a function with the same name as a 1222: virtual function, but with a type signature that does not match any 1223: declarations from the base class. 1224: 1.1.1.7 ! root 1225: `-Wsynth (C++ only)' ! 1226: Warn when g++'s synthesis behavior does not match that of cfront. ! 1227: For instance: ! 1228: ! 1229: struct A { ! 1230: operator int (); ! 1231: A& operator = (int); ! 1232: }; ! 1233: ! 1234: main () ! 1235: { ! 1236: A a,b; ! 1237: a = b; ! 1238: } 1.1.1.5 root 1239: 1.1.1.7 ! root 1240: In this example, g++ will synthesize a default `A& operator = ! 1241: (const A&);', while cfront will use the user-defined `operator ='. 1.1.1.5 root 1242: 1.1.1.7 ! root 1243: `-Werror' ! 1244: Make all warnings into errors. 1.1.1.5 root 1245:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.