Information on using C++


There are two different versions of C++ available on Athena, AT&T's version called cfront and the GNU version, g++.

Use

The AT&T version (now in its 2.0 release) translates your source code to C, and then compiles it as normal C code. This can cause some problems. If you get a warning about its code (not your code), for example, you can usually ignore it. CC is currently available on all platforms.

The GNU version is actually a direct C++ compiler. It is also available for all platforms on Athena.

To use the AT&T version, type:

add c++
CC filename.C
and for the GNU version, type:
add cygnus
g++ filename.C

Differences

There are several differences between the GNU and AT&T versions of C++:

Documentation

There is a manual page for G++ in the gnu locker. To access it, just type:

athena% add gnu
athena% man g++
In addition, there is an extended set of very helpful Emacs info files available. To access them, first start up Emacs:

athena% emacs
and inside Emacs type:

Meta-x info
When the info pages come up, you might want to go through the tutorial to learn how to move around; you access the tutorial by typing "h" in the info pages.

After you've gone through the tutorial, try typing:

g
and then type in:

(/mit/gnu/info/dir)Top
to get to the top-level GNU info pages; from there you can go to the section on "gcc" which also covers "g++".

There is not a lot of cfront specific documentation available. There is a readme file in the c++ locker which itemizes the changes from version 1.0 to version 2.0. The manual page documents the use of the CC command. Some hardcopy documentation, including the 2.0 release notes, is available in the consultants' office (11-115). If you wish, you may come over during our office hours to look at the manual. Unfortunately we only have one copy, so we can't let you remove it from the office.

For general C++ documentation, there are several books on the market. Lippman's C++ Primer is a good introduction, or look at books by Stroustrup for definitions of the evolving C++ language.

There are also interesting discussions going on in the news group comp.lang.c++.

Bugs

Bug reports on g++ and CC should be sent to bugs@mit.edu.