You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
5.1 KiB
HTML
87 lines
5.1 KiB
HTML
4 years ago
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>Invoking G++ - Using the GNU Compiler Collection (GCC)</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html">
|
||
|
<meta name="description" content="Using the GNU Compiler Collection (GCC)">
|
||
|
<meta name="generator" content="makeinfo 4.13">
|
||
|
<link title="Top" rel="start" href="index.html#Top">
|
||
|
<link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC">
|
||
|
<link rel="prev" href="Overall-Options.html#Overall-Options" title="Overall Options">
|
||
|
<link rel="next" href="C-Dialect-Options.html#C-Dialect-Options" title="C Dialect Options">
|
||
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
||
|
<!--
|
||
|
Copyright (C) 1988-2015 Free Software Foundation, Inc.
|
||
|
|
||
|
Permission is granted to copy, distribute and/or modify this document
|
||
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||
|
any later version published by the Free Software Foundation; with the
|
||
|
Invariant Sections being ``Funding Free Software'', the Front-Cover
|
||
|
Texts being (a) (see below), and with the Back-Cover Texts being (b)
|
||
|
(see below). A copy of the license is included in the section entitled
|
||
|
``GNU Free Documentation License''.
|
||
|
|
||
|
(a) The FSF's Front-Cover Text is:
|
||
|
|
||
|
A GNU Manual
|
||
|
|
||
|
(b) The FSF's Back-Cover Text is:
|
||
|
|
||
|
You have freedom to copy and modify this GNU Manual, like GNU
|
||
|
software. Copies published by the Free Software Foundation raise
|
||
|
funds for GNU development.-->
|
||
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
||
|
<style type="text/css"><!--
|
||
|
pre.display { font-family:inherit }
|
||
|
pre.format { font-family:inherit }
|
||
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
||
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
||
|
pre.smallexample { font-size:smaller }
|
||
|
pre.smalllisp { font-size:smaller }
|
||
|
span.sc { font-variant:small-caps }
|
||
|
span.roman { font-family:serif; font-weight:normal; }
|
||
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="node">
|
||
|
<a name="Invoking-G++"></a>
|
||
|
<a name="Invoking-G_002b_002b"></a>
|
||
|
<p>
|
||
|
Next: <a rel="next" accesskey="n" href="C-Dialect-Options.html#C-Dialect-Options">C Dialect Options</a>,
|
||
|
Previous: <a rel="previous" accesskey="p" href="Overall-Options.html#Overall-Options">Overall Options</a>,
|
||
|
Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a>
|
||
|
<hr>
|
||
|
</div>
|
||
|
|
||
|
<h3 class="section">3.3 Compiling C++ Programs</h3>
|
||
|
|
||
|
<p><a name="index-suffixes-for-C_002b_002b-source-97"></a><a name="index-C_002b_002b-source-file-suffixes-98"></a>C++ source files conventionally use one of the suffixes ‘<samp><span class="samp">.C</span></samp>’,
|
||
|
‘<samp><span class="samp">.cc</span></samp>’, ‘<samp><span class="samp">.cpp</span></samp>’, ‘<samp><span class="samp">.CPP</span></samp>’, ‘<samp><span class="samp">.c++</span></samp>’, ‘<samp><span class="samp">.cp</span></samp>’, or
|
||
|
‘<samp><span class="samp">.cxx</span></samp>’; C++ header files often use ‘<samp><span class="samp">.hh</span></samp>’, ‘<samp><span class="samp">.hpp</span></samp>’,
|
||
|
‘<samp><span class="samp">.H</span></samp>’, or (for shared template code) ‘<samp><span class="samp">.tcc</span></samp>’; and
|
||
|
preprocessed C++ files use the suffix ‘<samp><span class="samp">.ii</span></samp>’. GCC recognizes
|
||
|
files with these names and compiles them as C++ programs even if you
|
||
|
call the compiler the same way as for compiling C programs (usually
|
||
|
with the name <samp><span class="command">gcc</span></samp>).
|
||
|
|
||
|
<p><a name="index-g_002b_002b-99"></a><a name="index-c_002b_002b-100"></a>However, the use of <samp><span class="command">gcc</span></samp> does not add the C++ library.
|
||
|
<samp><span class="command">g++</span></samp> is a program that calls GCC and automatically specifies linking
|
||
|
against the C++ library. It treats ‘<samp><span class="samp">.c</span></samp>’,
|
||
|
‘<samp><span class="samp">.h</span></samp>’ and ‘<samp><span class="samp">.i</span></samp>’ files as C++ source files instead of C source
|
||
|
files unless <samp><span class="option">-x</span></samp> is used. This program is also useful when
|
||
|
precompiling a C header file with a ‘<samp><span class="samp">.h</span></samp>’ extension for use in C++
|
||
|
compilations. On many systems, <samp><span class="command">g++</span></samp> is also installed with
|
||
|
the name <samp><span class="command">c++</span></samp>.
|
||
|
|
||
|
<p><a name="index-invoking-_0040command_007bg_002b_002b_007d-101"></a>When you compile C++ programs, you may specify many of the same
|
||
|
command-line options that you use for compiling programs in any
|
||
|
language; or command-line options meaningful for C and related
|
||
|
languages; or options that are meaningful only for C++ programs.
|
||
|
See <a href="C-Dialect-Options.html#C-Dialect-Options">Options Controlling C Dialect</a>, for
|
||
|
explanations of options for languages related to C.
|
||
|
See <a href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options">Options Controlling C++ Dialect</a>, for
|
||
|
explanations of options that are meaningful only for C++ programs.
|
||
|
|
||
|
</body></html>
|
||
|
|