Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
g++(1)
Edit
PageHistory
Diff
Info
LikePages
G++ !!!G++ NAME SYNOPSIS DESCRIPTION OPTIONS PRAGMAS FILES SEE ALSO BUGS COPYING AUTHORS ---- !!NAME g++ - GNU project C++ Compiler !!SYNOPSIS g++ __[[__''option'' | ''filename'' ]... !!DESCRIPTION The C and C++ compilers are integrated; __g++__ is a script to call __gcc with options to recognize C++. gcc__ processes input files through one or more of four stages: preprocessing, compilation, assembly, and linking. This man page contains full descriptions for ''only'' C++ specific aspects of the compiler, though it also contains summaries of some general-purpose options. For a fuller explanation of the compiler, see __gcc__(__1__). C++ source files use one of the suffixes `__.C__', `__.cc__', `__.cxx__', `__.cpp__', or `__.c++__'; preprocessed C++ files use the suffix `__.ii__'. !!OPTIONS There are many command-line options, including options to control details of optimization, warnings, and code generation, which are common to both __gcc__ and __g++__. For full information on all options, see __gcc__(__1__). Options must be separate: `__-dr__' is quite different from `__-d -r__ '. Most `__-f__' and `__-W__' options have two contrary forms: __-f__''name'' and __-fno-__''name'' (or __-W__''name'' and __-Wno-__''name''). Only the non-default forms are shown here. __-c__ Compile or assemble the source files, but do not link. The compiler output is an object file corresponding to each source file. __-D__''macro'' Define macro ''macro'' with the string `__1__' as its definition. __-D__''macro''__=__''defn'' Define macro ''macro'' as ''defn''. __-E__ Stop after the preprocessing stage; do not run the compiler proper. The output is preprocessed source code, which is sent to the standard output. __-fall-virtual__ Treat all possible member functions as virtual, implicitly. All member functions (except for constructor functions and __new__ or __delete__ member operators) are treated as virtual functions of the class where they appear. This does not mean that all calls to these member functions will be made through the internal table of virtual functions. Under some circumstances, the compiler can determine that a call to a given virtual function can be made directly; in these cases the calls are direct in any case. __-fdollars-in-identifiers__ Permit the use of `__$__' in identifiers. Traditional C allowed the character `__$__' to form part of identifiers; by default, GNU C also allows this. However, ANSI C forbids `__$__' in identifiers, and GNU C++ also forbids it by default on most platforms (though on some platforms it's enabled by default for GNU C++ as well). __-felide-constructors__ Use this option to instruct the compiler to be smarter about when it can elide constructors. Without this flag, GNU C++ and cfront both generate effectively the same code for: A foo (); A x (foo ()); // x initialized by `foo ()', no ctor called A y = foo (); // call to `foo ()' heads to temporary, // y is initialized from the temporary. Note the difference! With this flag, GNU C++ initializes `__y__' directly from the call to __foo ()__ without going through a temporary. __-fenum-int-equiv__ Normally GNU C++ allows conversion of __enum__ to __int__, but not the other way around. Use this option if you want GNU C++ to allow conversion of __int__ to __enum__ as well. __-fexternal-templates__ Produce smaller code for template declarations, by generating only a single copy of each template function where it is defined. To use this option successfully, you must also mark all files that use templates with either `__#pragma implementation__' (the definition) or `__#pragma interface__' (declarations). When your code is compiled with `__-fexternal-templates__', all template instantiations are external. You must arrange for all necessary instantiations to appear in the implementation file; you can do this with a __typedef__ that references each instantiation needed. Conversely, when you compile using the default option `__-fno-external-templates__', all template instantiations are explicitly internal. __-fno-gnu-linker__ Do not output global initializations (such as C++ constructors and destructors) in the form used by the GNU linker (on systems where the GNU linker is the standard method of handling them). Use this option when you want to use a non-GNU linker, which also requires using the __collect2__ program to make sure the system linker includes constructors and destructors. (__collect2__ is included in the GNU CC distribution.) For systems which ''must'' use __collect2__, the compiler driver __gcc__ is configured to do this automatically. __-fmemoize-lookups__ __-fsave-memoized__ These flags are used to get the compiler to compile programs faster using heuristics. They are not on by default since they are only effective about half the time. The other half of the time programs compile more slowly (and take more memory). The first time the compiler must build a call to a member function (or reference to a data member), it must (1) determine whether the class implements member functions of that name; (2) resolve which member function to call (which involves figuring out what sorts of type conversions need to be made); and (3) check the visibility of the member function to the caller. All of this adds up to slower compilation. Normally, the second time a call is made to that member function (or reference to that data member), it must go through the same lengthy process again. This means that code like this cout makes six passes through all three steps. By using a software cache, a ``hit'' significantly reduces this cost. Unfortunately, using the cache introduces another layer of mechanisms which must be implemented, and so incurs its own overhead. `__-fmemoize-lookups__' enables the software cache. Because access privileges (visibility) to members and member functions may differ from one function context to the next, __g++__ may need to flush the cache. With the `__-fmemoize-lookups__' flag, the cache is flushed after every function that is compiled. The `-fsave-memoized' flag enables the same software cache, but when the compiler determines that the context of the last function compiled would yield the same access privileges of the next function to compile, it preserves the cache. This is most helpful when defining many member functions for the same class: with the exception of member functions which are friends of other classes, each member function has exactly the same access privileges as every other, and the cache need not be flushed. __-fno-default-inline__ Do not make member functions inline by default merely because they are defined inside the class scope. Otherwise, when you specify __-O__, member functions defined inside class scope are compiled inline by default; i.e., you don't need to add `__inline__' in front of the member function name. __-fno-strict-prototype__ Consider the declaration __int foo ();__. In C++, this means that the function __foo__ takes no arguments. In ANSI C, this is declared __int foo(void);__. With the flag `__-fno-strict-prototype__', declaring functions with no arguments is equivalent to declaring its argument list to be untyped, i.e., __int foo ();__ is equivalent to saying __int foo (...);__. __-fnonnull-objects__ Normally, GNU C++ makes conservative assumptions about objects reached through references. For example, the compiler must check that `__a__' is not null in code like the following: obj a.f (2); Checking that references of this sort have non-null values requires extra code, however, and it is unnecessary for many programs. You can use `__-fnonnull-objects__' to omit the checks for null, if your program doesn't require the default checking. __-fhandle-signatures__ __-fno-handle-signatures__ These options control the recognition of the __signature__ and __sigof__ constructs for specifying abstract types. By default, these constructs are not recognized. __-fthis-is-variable__ The incorporation of user-defined free store management into C++ has made assignment to __this__ an anachronism. Therefore, by default GNU C++ treats the type of __this__ in a member function of __class X__ to be __X *const__. In other words, it is illegal to assign to __this__ within a class member function. However, for backwards compatibility, you can invoke the old behavior by using `__-fthis-is-variable__'. __-g__ Produce debugging information in the operating system's native format (for DBX or SDB or DWARF). GDB also can work with this debugging information. On most systems that use DBX format, `__-g__' enables use of extra debugging information that only GDB can use. Unlike most other C compilers, GNU CC allows you to use `__-g__' with `__-O__'. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops. Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs. __-I__''dir'' Append directory ''dir'' to the list of directories searched for include files. __-L__''dir'' Add directory ''dir'' to the list of directories to be searched for `__-l__'. __-l__''library'' Use the library named ''library'' when linking. (C++ programs often require `-lg++' for successful linking.) __-nostdinc__ Do not search the standard system directories for header files. Only the directories you have specified with __-I__ options (and the current directory, if appropriate) are searched. __-nostdinc++__ Do not search for header files in the standard directories specific to C++, but do still search the other standard directories. (This option is used when building libg++.) __-O__ Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function. __-o__ ''file'' Place output in file ''file''. __-S__ Stop after the stage of compilation proper; do not assemble. The output is an assembler code file for each non-assembler input file specified. __-traditional__ Attempt to support some aspects of traditional C compilers. Specifically, for both C and C++ programs: In the preprocessor, comments convert to nothing at all, rather than to a space. This allows traditional token concatenation. In the preprocessor, macro arguments are recognized within string constants in a macro definition (and their values are stringified, though without additional quote marks, when they appear in such a context). The preprocessor always considers a string constant to end at a newline. The preprocessor does not predefine the macro ____STDC____ when you use `__-traditional__', but still predefines____GNUC____ (since the GNU extensions indicated by ____GNUC____ are not affected by `__-traditional__'). If you need to write header files that work differently depending on whether `__-traditional__' is in use, by testing both of these predefined macros you can distinguish four situations: GNU C, traditional GNU C, other ANSI C compilers, and other old C compilers. String ``constants'' are not necessarily constant; they are stored in writable space, and identical looking constants are allocated separately. For C++ programs only (not C), `__-traditional__' has one additional effect: assignment to __this__ is permitted. This is the same as the effect of `__-fthis-is-variable__'. __-U__''macro'' Undefine macro ''macro''. __-Wall__ Issue warnings for conditions which pertain to usage that we recommend avoiding and that we believe is easy to avoid, even in conjunction with macros. __-Wenum-clash__ Warn when converting between different enumeration types. __-Woverloaded-virtual__ In a derived class, the definitions of virtual functions must match the type signature of a virtual function declared in the base class. Use this option to request warnings when a derived class declares a function that may be an erroneous attempt to define a virtual function: that is, warn when a function with the same name as a virtual function in the base class, but with a type signature that doesn't match any virtual functions from the base class. __-Wtemplate-debugging__ When using templates in a C++ program, warn if debugging is not yet fully available. __-w__ Inhibit all warning messages. __+e__''N'' Control how virtual function definitions are used, in a fashion compatible with __cfront__ 1.x. !!PRAGMAS Two `__#pragma__' directives are supported for GNU C++, to permit using the same header file for two purposes: as a definition of interfaces to a given object class, and as the full definition of the contents of that object class. __#pragma interface__ Use this directive in header files that define object classes, to save space in most of the object files that use those classes. Normally, local copies of certain information (backup copies of inline member functions, debugging information, and the internal tables that implement virtual functions) must be kept in each object file that includes class definitions. You can use this pragma to avoid such duplication. When a header file containing `__#pragma interface__' is included in a compilation, this auxiliary information will not be generated (unless the main input source file itself uses `__#pragma implementation__'). Instead, the object files will contain references to be resolved at link time. __#pragma implementation__ __#pragma implementation __''objects''__.h__ Use this pragma in a main input file, when you want full output from included header files to be generated (and made globally visible). The included header file, in turn, should use `__#pragma interface__'. Backup copies of inline member functions, debugging information, and the internal tables used to implement virtual functions are all generated in implementation files. If you use `__#pragma implementation__' with no argument, it applies to an include file with the same basename as your source file; for example, in `__allclass.cc__', `__#pragma implementation__' by itself is equivalent to `__#pragma implementation __'. Use the string argument if you want a single implementation file to include code from multiple header files. There is no way to split up the contents of a single header file into multiple implementation files. !!FILES file.h C header (preprocessor) file file.i preprocessed C source file file.C C++ source file file.cc C++ source file file.cxx C++ source file file.s assembly language file file.o object file a.out link edited output'' TMPDIR''/cc temporary files'' LIBDIR''/cpp preprocessor'' LIBDIR''/cc1plus compiler'' LIBDIR''/collect linker front end needed on some machines'' LIBDIR''/libgcc.a GCC subroutine library /lib/crt[[01n].o start-up routine'' LIBDIR''/ccrt0 additional start-up routine for C++ /lib/libc.a standard C library, see intro(3) /usr/include standard directory for __#include__ files'' LIBDIR''/include standard gcc directory for __#include__ files'' LIBDIR''/g++-include additional g++ directory for __#include__ ''LIBDIR'' is usually __/usr/local/lib/__''machine''/''version''.'' TMPDIR'' comes from the environment variable __TMPDIR__ (default __/usr/tmp__ if available, else __/tmp__). !!SEE ALSO gcc(1), cpp(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1). `__gcc__', `__cpp__', `__as__',__`__ld__',__ and `__gdb__' entries in __info__.'' Using and Porting GNU CC (for version 2.0)'', Richard M. Stallman; ''The C Preprocessor'', Richard M. Stallman; ''Debugging with GDB: the GNU Source-Level Debugger'', Richard M. Stallman and Roland H. Pesch; ''Using as: the GNU Assembler'', Dean Elsner, Jay Fenlason ''gld: the GNU linker'', Steve Chamberlain and Roland Pesch. !!BUGS For instructions on how to report bugs, see the GCC manual. !!COPYING Copyright (c) 1991, 1992, 1993 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English. !!AUTHORS See the GNU CC Manual for the contributors to GNU CC. ----
One page links to
g++(1)
:
Man1g
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.