|
|
1.1.1.4 ! root 1: .\" Copyright (c) 1991, 1992 Free Software Foundation -*-Text-*- 1.1 root 2: .\" See section COPYING for conditions for redistribution 3: .\" FIXME: no info here on predefines. Should there be? extra for C++... 1.1.1.4 ! root 4: .TH G++ 1 "30apr1993" "GNU Tools" "GNU Tools" 1.1 root 5: .de BP 6: .sp 7: .ti \-.2i 8: \(** 9: .. 10: .SH NAME 1.1.1.4 ! root 11: g++ \- GNU project C++ Compiler (v2.4) 1.1 root 12: .SH SYNOPSIS 13: .RB g++ " [" \c 14: .IR option " | " filename " ].\|.\|. 15: .SH DESCRIPTION 1.1.1.3 root 16: The C and C++ compilers are integrated; 17: .B g++ 18: is a script to call 19: .B gcc with options to recognize C++. 20: .B gcc 21: processes input files 1.1 root 22: through one or more of four stages: preprocessing, compilation, 23: assembly, and linking. This man page contains full descriptions for 24: .I only 25: C++ specific aspects of the compiler, though it also contains 26: summaries of some general-purpose options. For a fuller explanation 27: of the compiler, see 28: .BR gcc ( 1 ). 29: 30: C++ source files use one of the suffixes `\|\c 31: .B .C\c 32: \&\|', `\|\c 33: .B .cc\c 34: \&\|', or `\|\c 35: .B .cxx\c 1.1.1.3 root 36: \&\|'; preprocessed C++ files use the suffix `\|\c 37: .B .ii\c 1.1 root 38: \&\|'. 39: .SH OPTIONS 40: There are many command-line options, including options to control 41: details of optimization, warnings, and code generation, which are 42: common to both 43: .B gcc 44: and 45: .B g++\c 46: \&. For full information on all options, see 47: .BR gcc ( 1 ). 48: 49: Options must be separate: `\|\c 50: .B \-dr\c 51: \&\|' is quite different from `\|\c 52: .B \-d \-r 53: \&\|'. 54: 55: Most `\|\c 56: .B \-f\c 57: \&\|' and `\|\c 58: .B \-W\c 59: \&\|' options have two contrary forms: 60: .BI \-f name 61: and 62: .BI \-fno\- name\c 63: \& (or 64: .BI \-W name 65: and 66: .BI \-Wno\- name\c 67: \&). Only the non-default forms are shown here. 68: 69: .TP 70: .B \-c 71: Compile or assemble the source files, but do not link. The compiler 72: output is an object file corresponding to each source file. 73: .TP 74: .BI \-D macro 75: Define macro \c 76: .I macro\c 77: \& with the string `\|\c 78: .B 1\c 79: \&\|' as its definition. 80: .TP 81: .BI \-D macro = defn 82: Define macro \c 83: .I macro\c 84: \& as \c 85: .I defn\c 86: \&. 87: .TP 88: .B \-E 89: Stop after the preprocessing stage; do not run the compiler proper. The 90: output is preprocessed source code, which is sent to the 91: standard output. 92: .TP 93: .B \-fall\-virtual 1.1.1.4 ! root 94: Treat all possible member functions as virtual, implicitly. All ! 95: member functions (except for constructor functions and ! 96: .B new ! 97: or ! 98: .B delete ! 99: member operators) are treated as virtual functions of the class where ! 100: they appear. ! 101: ! 102: This does not mean that all calls to these member functions will be ! 103: made through the internal table of virtual functions. Under some ! 104: circumstances, the compiler can determine that a call to a given ! 105: virtual function can be made directly; in these cases the calls are ! 106: direct in any case. 1.1 root 107: .TP 108: .B \-fdollars\-in\-identifiers 109: Permit the use of `\|\c 110: .B $\c 111: \&\|' in identifiers. 112: Traditional C allowed the character `\|\c 113: .B $\c 114: \&\|' to form part of identifiers; by default, GNU C also 115: allows this. However, ANSI C forbids `\|\c 116: .B $\c 117: \&\|' in identifiers, and GNU C++ also forbids it by default on most 118: platforms (though on some platforms it's enabled by default for GNU 119: C++ as well). 120: .TP 121: .B \-felide\-constructors 122: Use this option to instruct the compiler to be smarter about when it can 123: elide constructors. Without this flag, GNU C++ and cfront both 124: generate effectively the same code for: 125: .sp 126: .br 127: A\ foo\ (); 128: .br 129: A\ x\ (foo\ ());\ \ \ //\ x\ initialized\ by\ `foo\ ()',\ no\ ctor\ called 130: .br 131: A\ y\ =\ foo\ ();\ \ \ //\ call\ to\ `foo\ ()'\ heads\ to\ temporary, 132: .br 133: \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ //\ y\ is\ initialized\ from\ the\ temporary. 134: .br 135: .sp 136: Note the difference! With this flag, GNU C++ initializes `\|\c 137: .B y\c 138: \&\|' directly 139: from the call to 140: .B foo () 141: without going through a temporary. 142: .TP 143: .B \-fenum\-int\-equiv 144: Normally GNU C++ allows conversion of 145: .B enum 146: to 147: .B int\c 148: \&, but not the other way around. Use this option if you want GNU C++ 149: to allow conversion of 150: .B int 151: to 152: .B enum 153: as well. 154: .TP 1.1.1.4 ! root 155: .B \-fno\-gnu\-linker ! 156: Do not output global initializations (such as C++ constructors and ! 157: destructors) in the form used by the GNU linker (on systems where the GNU ! 158: linker is the standard method of handling them). Use this option when ! 159: you want to use a non-GNU linker, which also requires using the ! 160: .B collect2 ! 161: program to make sure the system linker includes ! 162: constructors and destructors. (\c ! 163: .B collect2 ! 164: is included in the GNU CC distribution.) For systems which ! 165: .I must ! 166: use ! 167: .B collect2\c ! 168: \&, the compiler driver ! 169: .B gcc ! 170: is configured to do this automatically. 1.1 root 171: .TP 172: .B \-fmemoize\-lookups 173: .TP 174: .B \-fsave\-memoized 175: These flags are used to get the compiler to compile programs faster 176: using heuristics. They are not on by default since they are only effective 177: about half the time. The other half of the time programs compile more 178: slowly (and take more memory). 179: 180: The first time the compiler must build a call to a member function (or 181: reference to a data member), it must (1) determine whether the class 182: implements member functions of that name; (2) resolve which member 183: function to call (which involves figuring out what sorts of type 184: conversions need to be made); and (3) check the visibility of the member 185: function to the caller. All of this adds up to slower compilation. 186: Normally, the second time a call is made to that member function (or 187: reference to that data member), it must go through the same lengthy 188: process again. This means that code like this 189: .sp 190: .br 191: \ \ cout\ <<\ "This\ "\ <<\ p\ <<\ "\ has\ "\ <<\ n\ <<\ "\ legs.\en"; 192: .br 193: .sp 194: makes six passes through all three steps. By using a software cache, 195: a ``hit'' significantly reduces this cost. Unfortunately, using the 196: cache introduces another layer of mechanisms which must be implemented, 197: and so incurs its own overhead. `\|\c 198: .B \-fmemoize\-lookups\c 199: \&\|' enables 200: the software cache. 201: 202: Because access privileges (visibility) to members and member functions 203: may differ from one function context to the next, 204: .B g++ 205: may need to flush the cache. With the `\|\c 206: .B \-fmemoize\-lookups\c 207: \&\|' flag, the cache is flushed after every 208: function that is compiled. The `\|\c 209: \-fsave\-memoized\c 210: \&\|' flag enables the same software cache, but when the compiler 211: determines that the context of the last function compiled would yield 212: the same access privileges of the next function to compile, it 213: preserves the cache. 214: This is most helpful when defining many member functions for the same 215: class: with the exception of member functions which are friends of 216: other classes, each member function has exactly the same access 217: privileges as every other, and the cache need not be flushed. 218: .TP 219: .B \-fno\-default\-inline 1.1.1.4 ! root 220: Do not make member functions inline by default merely because they are ! 221: defined inside the class scope. Otherwise, when you specify ! 222: .B \-O\c ! 223: \&, member functions defined inside class scope are compiled ! 224: inline by default; i.e., you don't need to add `\|\c 1.1 root 225: .B inline\c 1.1.1.4 ! root 226: \&\|' in front of ! 227: the member function name. 1.1 root 228: .TP 229: .B \-fno\-strict\-prototype 230: Consider the declaration \c 231: .B int foo ();\c 232: \&. In C++, this means that the 233: function \c 234: .B foo\c 235: \& takes no arguments. In ANSI C, this is declared 236: .B int foo(void);\c 237: \&. With the flag `\|\c 238: .B \-fno\-strict\-prototype\c 239: \&\|', 240: declaring functions with no arguments is equivalent to declaring its 241: argument list to be untyped, i.e., \c 242: .B int foo ();\c 243: \& is equivalent to 244: saying \c 245: .B int foo (...);\c 246: \&. 247: .TP 248: .B \-fnonnull\-objects 249: Normally, GNU C++ makes conservative assumptions about objects reached 250: through references. For example, the compiler must check that `\|\c 251: .B a\c 252: \&\|' is not null in code like the following: 253: .br 254: \ \ \ \ obj\ &a\ =\ g\ (); 255: .br 256: \ \ \ \ a.f\ (2); 257: .br 258: Checking that references of this sort have non-null values requires 259: extra code, however, and it is unnecessary for many programs. You can 260: use `\|\c 261: .B \-fnonnull\-objects\c 262: \&\|' to omit the checks for null, if your program doesn't require the 263: default checking. 264: .TP 265: .B \-fthis\-is\-variable 266: The incorporation of user-defined free store management into C++ has 267: made assignment to \c 268: .B this\c 269: \& an anachronism. Therefore, by default GNU 270: C++ treats the type of \c 271: .B this\c 272: \& in a member function of \c 273: .B class X\c 274: \& 275: to be \c 276: .B X *const\c 277: \&. In other words, it is illegal to assign to 278: \c 279: .B this\c 280: \& within a class member function. However, for backwards 281: compatibility, you can invoke the old behavior by using 282: \&`\|\c 283: .B \-fthis\-is\-variable\c 284: \&\|'. 285: .TP 286: .B \-g 287: Produce debugging information in the operating system's native format 288: (for DBX or SDB or DWARF). GDB also can work with this debugging 289: information. On most systems that use DBX format, `\|\c 290: .B \-g\c 291: \&\|' enables use 292: of extra debugging information that only GDB can use. 293: 294: Unlike most other C compilers, GNU CC allows you to use `\|\c 295: .B \-g\c 296: \&\|' with 297: `\|\c 298: .B \-O\c 299: \&\|'. The shortcuts taken by optimized code may occasionally 300: produce surprising results: some variables you declared may not exist 301: at all; flow of control may briefly move where you did not expect it; 302: some statements may not be executed because they compute constant 303: results or their values were already at hand; some statements may 304: execute in different places because they were moved out of loops. 305: 306: Nevertheless it proves possible to debug optimized output. This makes 307: it reasonable to use the optimizer for programs that might have bugs. 308: .TP 309: .BI "\-I" "dir"\c 310: \& 311: Append directory \c 312: .I dir\c 313: \& to the list of directories searched for include files. 314: .TP 315: .BI "\-L" "dir"\c 316: \& 317: Add directory \c 318: .I dir\c 319: \& to the list of directories to be searched 320: for `\|\c 321: .B \-l\c 322: \&\|'. 323: .TP 324: .BI \-l library\c 325: \& 326: Use the library named \c 327: .I library\c 328: \& when linking. (C++ programs often require `\|\c 329: \-lg++\c 330: \&\|' for successful linking.) 331: .TP 1.1.1.4 ! root 332: .B \-nostdinc ! 333: Do not search the standard system directories for header files. Only ! 334: the directories you have specified with ! 335: .B \-I ! 336: options (and the current directory, if appropriate) are searched. ! 337: .TP ! 338: .B \-nostdinc++ ! 339: Do not search for header files in the standard directories specific to ! 340: C++, but do still search the other standard directories. (This option ! 341: is used when building libg++.) ! 342: .TP 1.1 root 343: .B \-O 344: Optimize. Optimizing compilation takes somewhat more time, and a lot 345: more memory for a large function. 346: .TP 347: .BI "\-o " file\c 348: \& 349: Place output in file \c 350: .I file\c 351: \&. 352: .TP 353: .B \-S 354: Stop after the stage of compilation proper; do not assemble. The output 355: is an assembler code file for each non-assembler input 356: file specified. 357: .TP 358: .B \-traditional 359: Attempt to support some aspects of traditional C compilers. 360: 361: Specifically, for both C and C++ programs: 362: .TP 363: \ \ \ \(bu 364: In the preprocessor, comments convert to nothing at all, rather than 365: to a space. This allows traditional token concatenation. 366: .TP 367: \ \ \ \(bu 368: In the preprocessor, macro arguments are recognized within string 369: constants in a macro definition (and their values are stringified, 370: though without additional quote marks, when they appear in such a 371: context). The preprocessor always considers a string constant to end 372: at a newline. 373: .TP 374: \ \ \ \(bu 375: The preprocessor does not predefine the macro \c 376: .B __STDC__\c 377: \& when you use 378: `\|\c 379: .B \-traditional\c 380: \&\|', but still predefines\c 381: .B __GNUC__\c 382: \& (since the GNU extensions indicated by 383: .B __GNUC__\c 384: \& are not affected by 385: `\|\c 386: .B \-traditional\c 387: \&\|'). If you need to write header files that work 388: differently depending on whether `\|\c 389: .B \-traditional\c 390: \&\|' is in use, by 391: testing both of these predefined macros you can distinguish four 392: situations: GNU C, traditional GNU C, other ANSI C compilers, and 393: other old C compilers. 394: .TP 395: \ \ \ \(bu 396: In the preprocessor, comments convert to nothing at all, rather than 397: to a space. This allows traditional token concatenation. 398: .TP 399: \ \ \ \(bu 400: In the preprocessor, macro arguments are recognized within string 401: constants in a macro definition (and their values are stringified, 402: though without additional quote marks, when they appear in such a 403: context). The preprocessor always considers a string constant to end 404: at a newline. 405: .TP 406: \ \ \ \(bu 407: The preprocessor does not predefine the macro \c 408: .B __STDC__\c 409: \& when you use 410: `\|\c 411: .B \-traditional\c 412: \&\|', but still predefines\c 413: .B __GNUC__\c 414: \& (since the GNU extensions indicated by 415: .B __GNUC__\c 416: \& are not affected by 417: `\|\c 418: .B \-traditional\c 419: \&\|'). If you need to write header files that work 420: differently depending on whether `\|\c 421: .B \-traditional\c 422: \&\|' is in use, by 423: testing both of these predefined macros you can distinguish four 424: situations: GNU C, traditional GNU C, other ANSI C compilers, and 425: other old C compilers. 426: .PP 427: .TP 428: \ \ \ \(bu 429: String ``constants'' are not necessarily constant; they are stored in 430: writable space, and identical looking constants are allocated 1.1.1.4 ! root 431: separately. 1.1 root 432: 433: For C++ programs only (not C), `\|\c 434: .B \-traditional\c 435: \&\|' has one additional effect: assignment to 436: .B this 437: is permitted. This is the same as the effect of `\|\c 438: .B \-fthis\-is\-variable\c 439: \&\|'. 440: .TP 441: .BI \-U macro 442: Undefine macro \c 443: .I macro\c 444: \&. 445: .TP 446: .B \-Wall 447: Issue warnings for conditions which pertain to usage that we recommend 448: avoiding and that we believe is easy to avoid, even in conjunction 449: with macros. 450: .TP 451: .B \-Wenum\-clash 452: Warn when converting between different enumeration types. 453: .TP 454: .B \-Woverloaded\-virtual 455: In a derived class, the definitions of virtual functions must match 456: the type signature of a virtual function declared in the base class. 457: Use this option to request warnings when a derived class declares a 458: function that may be an erroneous attempt to define a virtual 459: function: that is, warn when a function with the same name as a 460: virtual function in the base class, but with a type signature that 461: doesn't match any virtual functions from the base class. 462: .TP 1.1.1.4 ! root 463: .B \-Wtemplate\-debugging ! 464: When using templates in a C++ program, warn if debugging is not yet ! 465: fully available. ! 466: .TP 1.1 root 467: .B \-w 468: Inhibit all warning messages. 1.1.1.4 ! root 469: .TP ! 470: .BI +e N ! 471: Control how virtual function definitions are used, in a fashion ! 472: compatible with ! 473: .B cfront ! 474: 1.x. 1.1 root 475: .PP 476: 477: .SH PRAGMAS 478: Two `\|\c 479: .B #pragma\c 480: \&\|' directives are supported for GNU C++, to permit using the same 481: header file for two purposes: as a definition of interfaces to a given 482: object class, and as the full definition of the contents of that object class. 483: .TP 484: .B #pragma interface 485: Use this directive in header files that define object classes, to save 486: space in most of the object files that use those classes. Normally, 487: local copies of certain information (backup copies of inline member 488: functions, debugging information, and the internal tables that 489: implement virtual functions) must be kept in each object file that 490: includes class definitions. You can use this pragma to avoid such 491: duplication. When a header file containing `\|\c 492: .B #pragma interface\c 493: \&\|' is included in a compilation, this auxiliary information 494: will not be generated (unless the main input source file itself uses 495: `\|\c 496: .B #pragma implementation\c 497: \&\|'). Instead, the object files will contain references to be 498: resolved at link time. 499: .tr !" 500: .TP 501: .B #pragma implementation 502: .TP 503: .BI "#pragma implementation !" objects .h! 504: Use this pragma in a main input file, when you want full output from 505: included header files to be generated (and made globally visible). 506: The included header file, in turn, should use `\|\c 507: .B #pragma interface\c 508: \&\|'. 509: Backup copies of inline member functions, debugging information, and 510: the internal tables used to implement virtual functions are all 511: generated in implementation files. 512: 513: If you use `\|\c 514: .B #pragma implementation\c 515: \&\|' with no argument, it applies to an include file with the same 516: basename as your source file; for example, in `\|\c 517: .B allclass.cc\c 518: \&\|', `\|\c 519: .B #pragma implementation\c 520: \&\|' by itself is equivalent to `\|\c 521: .B 522: #pragma implementation "allclass.h"\c 523: \&\|'. Use the string argument if you want a single implementation 524: file to include code from multiple header files. 525: 526: There is no way to split up the contents of a single header file into 527: multiple implementation files. 528: .SH FILES 529: .ta \w'LIBDIR/g++\-include 'u 530: file.h C header (preprocessor) file 531: .br 532: file.i preprocessed C source file 533: .br 534: file.C C++ source file 535: .br 536: file.cc C++ source file 537: .br 538: file.cxx C++ source file 539: .br 540: file.s assembly language file 541: .br 542: file.o object file 543: .br 544: a.out link edited output 545: .br 546: \fITMPDIR\fR/cc\(** temporary files 547: .br 548: \fILIBDIR\fR/cpp preprocessor 549: .br 550: \fILIBDIR\fR/cc1plus compiler 551: .br 552: \fILIBDIR\fR/collect linker front end needed on some machines 553: .br 554: \fILIBDIR\fR/libgcc.a GCC subroutine library 555: .br 556: /lib/crt[01n].o start-up routine 557: .br 558: \fILIBDIR\fR/ccrt0 additional start-up routine for C++ 559: .br 560: /lib/libc.a standard C library, see 561: .IR intro (3) 562: .br 563: /usr/include standard directory for 564: .B #include 565: files 566: .br 567: \fILIBDIR\fR/include standard gcc directory for 568: .B #include 569: files 570: .br 571: \fILIBDIR\fR/g++\-include additional g++ directory for 572: .B #include 573: .sp 574: .I LIBDIR 575: is usually 576: .B /usr/local/lib/\c 577: .IR machine / version . 578: .br 579: .I TMPDIR 580: comes from the environment variable 581: .B TMPDIR 582: (default 583: .B /usr/tmp 584: if available, else 585: .B /tmp\c 586: \&). 587: .SH "SEE ALSO" 588: gcc(1), cpp(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1). 589: .br 590: .RB "`\|" gcc "\|', `\|" cpp \|', 591: .RB `\| as \|', `\| ld \|', 592: and 593: .RB `\| gdb \|' 594: entries in 595: .B info\c 596: \&. 597: .br 598: .I 599: Using and Porting GNU CC (for version 2.0)\c 1.1.1.4 ! root 600: , Richard M. Stallman; 1.1 root 601: .I 602: The C Preprocessor\c 1.1.1.4 ! root 603: , Richard M. Stallman; 1.1 root 604: .I 1.1.1.4 ! root 605: Debugging with GDB: the GNU Source-Level Debugger\c ! 606: , Richard M. Stallman and Roland H. Pesch; 1.1 root 607: .I 608: Using as: the GNU Assembler\c 1.1.1.4 ! root 609: , Dean Elsner, Jay Fenlason & friends; 1.1 root 610: .I 611: gld: the GNU linker\c 1.1.1.4 ! root 612: , Steve Chamberlain and Roland Pesch. 1.1 root 613: 614: .SH BUGS 1.1.1.4 ! root 615: For instructions on how to report bugs, see the GCC manual. ! 616: 1.1 root 617: .SH COPYING 1.1.1.4 ! root 618: Copyright (c) 1991, 1992, 1993 Free Software Foundation, Inc. 1.1 root 619: .PP 620: Permission is granted to make and distribute verbatim copies of 621: this manual provided the copyright notice and this permission notice 622: are preserved on all copies. 623: .PP 624: Permission is granted to copy and distribute modified versions of this 625: manual under the conditions for verbatim copying, provided that the 626: entire resulting derived work is distributed under the terms of a 627: permission notice identical to this one. 628: .PP 629: Permission is granted to copy and distribute translations of this 630: manual into another language, under the above conditions for modified 631: versions, except that this permission notice may be included in 632: translations approved by the Free Software Foundation instead of in 633: the original English. 634: .SH AUTHORS 635: See the GNU CC Manual for the contributors to GNU CC.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.