Revision/Update Information: This is a revised manual.
Software Version: DIGITAL C++ Version 6.0 for DIGITAL UNIX
Digital Equipment Corporation
Maynard, Massachusetts
The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this document.
The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license.
The following are trademarks of Digital Equipment Corporation: DEC, DEC FUSE, DECthreads, Ladebug, OpenVMS, ULTRIX, VAX, VAX DOCUMENT, VMS, the DIGITAL C++ logo, and the DIGITAL logo.
The following are third-party trademarks:
AT&T is a registered trademark of American Telephone and Telegraph Company.
Hewlett-Packard is a registered tradmark of the Hewlett-Packard Company.
IEEE is a registered trademark of the Institute of Electrical and Electronics Engineers, Inc.
Microsoft is a registered trademark, and Visual C++ is a trademark of Microsoft Corporation.
OSF/1 is a registered tradmark of the Open Software Foundation, Inc.
POSIX is a registered certification mark of the Institute of Electrical and Electronic Engineers.
UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.
Portions of the ANSI C++ Standard Library have been implemented using source licensed from and copyrighted by Rogue Wave Software, Inc.
Information pertaining to the C++ Standard Library has been edited and reprinted with permission of, Rogue Wave Software, Inc. All rights reserved.
Portions copyright 1994-1996 Rogue Wave Software, Inc.
ZK6388
This document is available on CD-ROM.
Contents | Index |
This manual contains information for developing and debugging DIGITAL C++ programs on DIGITAL UNIX systems, and includes information on other DIGITAL UNIX features and tools that work with DIGITAL C++.
This manual is intended for experienced programmers who need to develop DIGITAL C++ programs on DIGITAL UNIX systems. Users of this manual should have a basic understanding of the C++ language and some familiarity with the DIGITAL UNIX operating system.
This manual is organized as follows:
The following documents contain information associated with topics in this manual:
The following documents are not included in the DIGITAL C++ documentation set. Refer to them for additional information on the C++ programming language, DEC C, or DIGITAL UNIX programming.
Table 1 lists the conventions used in this manual.
Convention | Meaning |
---|---|
% | A percent sign (%) is the default user prompt. |
class complex{
. . . }; |
A vertical ellipsis indicates that some intervening program code or output is not shown. Only the more pertinent material is shown in the example. |
,... | A horizontal ellipsis in a syntax description indicates that you can enter additional parameters, options, or values. A comma preceding the ellipsis indicates that successive items must be separated by commas. |
The
generic
class...
The get() function... |
Monospaced type denotes the names of DIGITAL C++ language elements, and also the names of classes, members, and nonmembers. Monospaced type is also used in text to reference code elements displayed in examples and file-name extensions. |
italic | Italic type denotes the names of variables that appear as parameters or in arguments to functions, and also denotes book titles. |
boldface | Boldface type in text indicates the first instance of terms defined in text. |
UPPERCASE
lowercase |
The DIGITAL UNIX operating system distinquishes between uppercase and lowercase characters. Literal strings that appear in text, examples, syntax descriptions, and function definitions must be entered exactly as shown. |
cxx (1) | Cross-references to reference pages include the appropriate section number in parentheses. |
You may send comments or suggestions regarding this manual, or any DIGITAL C++ document, by electronic mail to the following Internet address:
cxx_docs@bookie.enet.dec.com
If you have access to a FAX machine, you may send your comments or suggestions to:
DIGITAL C++ Documentation, ZKO2-3/K35
603-884-0120
This chapter provides information about the basic steps involved in developing a DIGITAL C++ program on a DIGITAL UNIX system. It explains how to compile, link, and debug DIGITAL C++ programs.
DIGITAL C++ is an implementation of the C++ programming language. The
DIGITAL C++ compiler is part of the DIGITAL UNIX compiler system. See
the DIGITAL UNIX Programmer's Guide for program development
information that applies to all DIGITAL UNIX languages, such as using
the compiler system, creating shared libraries, profiling, and
optimization.
1.1 Compiling a DIGITAL C++ Program
The cxx command invokes the DIGITAL C++ compiler. For information about using the cxx (DIGITAL C++ Compiler) command, including a description of command options, refer to the cxx(1) reference page. For information about this release, see the DIGITAL C++ Version 6.0 Release Notes for DIGITAL UNIX Systems.
You can compile a mixture of C++ and C source code by entering a single cxx compile command. The DIGITAL C++ compiler distinguishes between C++ source files (for example, .cxx) and C source files (for example, .c) based on their file extensions, and compiles the modules appropriately.
Unless you use the -x option to direct
the DIGITAL C++ compiler to ignore file-name extensions, passing a
file with a .c extension to the cxx command causes the compiler driver to treat
the file as a C file and pass it on to the cc command. If the file contains C++ code
instead of C code, the compilation may produce errors.
1.2 Linking a DIGITAL C++ Program
DIGITAL C++ uses cc to invoke the ld linker to generate code. Always use the cxx command to invoke the linker.
Linking through the cxx command ensures that all the necessary link options are passed to the ld linker. If your DIGITAL C++ program is not linked properly, some static objects will not be initialized at program startup.
If you choose to use the ld linker directly, you may need to modify your ld command whenever you install a new version of the DIGITAL C++ compiler or the DIGITAL UNIX operating system. After doing such an installation, you should invoke the cxx command and specify the -v option to display the ld command in use. Then, compare this ld command with your ld command and make any necessary changes. Note that you must link with cxx to use automatic template instantiation.
See the cxx(1) and the ld(1) reference pages for more information.
1.3 Name Demangling
The C++ compiler encodes type information in function names to enable type-safe linkage. This encoding is called name mangling. Function name mangling allows object code to have distinct names for functions that share the same name in the C++ source code and enables type-safe linkage.
It is often difficult to decipher mangled names that may appear in diagnostic messages from system tools such as the ld linker. A name demangler is provided to translate such mangled names into the function names that appear in the source code, so that they are recognizable by the user. You can use either the cxx command or the demangle command to help interpret mangled messages from the linker. If you use the cxx command to invoke the linker, DIGITAL C++ pipes any linker output to the name demangler unless you specify the -nodemangle option.
The demangle command reads each file in sequence, demangles any names encoded by DIGITAL C++, and displays the results on the standard output device. See the demangle(1) reference page for more information.
Syntax
demangle [-show_mangled_name][-no_vtable_info][-][file...] |
If no input file is given, or if a minus sign is encountered as an argument (for example, demangle -), the demangle command reads from the standard input file. The demangle utility supports the processing of 8-bit characters.
Options
- | Read from the standard input file. |
-show_mangled_name | Display encoded name in parentheses after demangled name. |
-no_vtable_info | Suppress the display of information concerning internal symbols (specifically __vtbl and __btbl ). |
Examples
demangle file |
This command demangles a file containing DIGITAL C++ encoded names.
ld main.o foo.o |& demangle |
This command (from the C shell) demangles the output from the linker (ld) when linking the main.o and foo.o files.
cxx foo.cxx |& demangle |
This command (from the C shell) demangles the output from the linker
when it is invoked implicitly through the cxx command to compile foo.cxx.
1.4 C++ Standard Library
The C++ Standard Library provided with this release defines a complete specification of the Final Draft International ANSI C++ Standard (FDIS), with some differences, as described in the DIGITAL C++ Version 6.0 Release Notes for DIGITAL UNIX Systems.
The Standard Library provided in this release includes for the first time the ANSI locale and iostream libraries.
Some of the components in the C++ Standard Library are designed to replace nonstandard components that are currently distributed in the DIGITAL C++ Class Library. However, DIGITAL will continue to provide the DIGITAL C++ Class Library.
Because the standardization process for the C++ Standard Library is not yet completed, DIGITAL cannot guarantee that this version of the library is compatible with any past or future releases. For this reason, DIGITAL ships the run-time portion of the library in object rather than shareable form.
Linking to the DIGITAL C++ Standard Library
When you use the cxx command to compile and link programs that use the C++ Standard Library, no special switches are required. The C++ driver automatically includes the Standard Library run-time support (-lcxxstd) on the link command, and automatic template instantiation (-pt ) is the default mode.
For example, to build a program called prog.cxx that uses the Standard Library, you enter the following command:
cxx prog.cxx |
For detailed information about the Standard Library, refer to
Chapter 7.
1.5 C++ Class Library
Reusing code is a cornerstone of object-oriented programming. To minimize the time it takes to develop new applications, a set of reusable classes is an essential part of DIGITAL C++. Class libraries offer a variety of predefined classes that enable you to work more efficiently. See the DEC C++ Class Library Reference Manual for a detailed explanation of the class library packages supplied with DIGITAL C++. The iostream class library package is from AT&T. See The AT&T C++ Language System, Release 2.0, Library Manual for a description of this package.
Linking to the C++ Class Library
Most of the C++ Class Library packages are automatically included in your program when needed. However, when using the complex package, you must provide the following explicit information for the linker:
-lcomplex -lm |
To use the task package, specify the following when linking using the cxx command:
-threads -ltask |
For example:
cxx thread_program.cxx -threads -ltask |
If you link using the -non_shared option to the cxx command, you must also specify -lcmalib. For example:
cxx -non_shared thread_program.cxx -threads -ltask -lcmalib |
These and other Class Library packages are documented in the
DEC C++ Class Library Reference Manual.
1.6 Debugging
The Ladebug Debugger is a source-level debugger developed to support DIGITAL C++. The dbx debugger does not support debugging C++ programs. For details on using the Ladebug Debugger, see Chapter 9.
Next | Contents | Index |