[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] .cc -> .cpp

From: Werner LEMBERG
Subject: Re: [Groff] .cc -> .cpp
Date: Tue, 15 Apr 2003 17:56:39 +0200 (CEST)

> > I've finally renamed all *.cc files to *.cpp.
> Why was this needed?

At least two compilers (MS VC++ and the C++ on IBM's z/OS) don't like
`.cc'.  The former can't use .cc at all, the latter needs the strange
switch `-+' to accept .cc.

Below a message from Nelson Beebe regarding C++ extensions.



>> I plan to rename all *.cc files to *.cpp in the groff package to make
>> it more compatible with some compilers.  MS VC++ needs that, and the
>> C++ compiler on IBM's z/OS machines doesn't understand .cc by default.
>> Do you see any problems with other C++ compilers?

Here are some extracts from man pages on all of the various systems
that I work on (16 major flavors of Unix):

Sun Solaris CC:
        file.C                        Input file                       Input file
        file.c++                      Input file
        file.cpp                      Input file
        file.cxx                      Input file
gcc-3.2.2 (all platforms):
           C++ source code which must be preprocessed.  Note that in
           .cxx, the last two letters must both be literally x.
           Likewise, .C refers to a literal capital C.
gcc-3.2.1 (FreeBSD):
        file.C             C++ source file            C++ source file
        file.cxx           C++ source file
        the language is determined by the file suffixes
        (.c, .cpp, .C, .cxx, .f, .f90, .s)
SGI IRIX 6.5 OCC [old (cfront-based) C++ compiler]:
        file.{C,c,c++,cc,cxx}           C++ source files.
Portland Group pgCC:
        file.C                        C++ source file                       C++ source file
        file.cpp                      C++ source file
Intel icc (IA-32) and ecc (IA-64):
        fileN is a C/C++ source (.C .c .cc .cpp .cxx .i) ...
HP/Compaq/DEC OSF/1:
        .cxx, .CXX, .cpp, .CPP, .cc, .CC, or .C C++ source code.
        .hxx          C++ header file
HP/Compaq/DEC OSF/1 5.1:
        .cxx, .CXX, .cpp .CPP .cc, .CC, .C, .c++        C++ source code
        .hxx          C++ header file
IBM AIX 4.2 xlC:
        Input files may be any of the following:
        1. file name with .C suffix: C++ source file
        2. file name with .i suffix: preprocessed C or C++ source file
        3. file name with .c suffix: C source file
        4. file name with .o suffix: object file for ld command
        5. file name with .s suffix: assembler source file

The IBM AIX compiler seems the most restrictive, so I tried some of
the other suffixes: these produced fatal compilation errors:

        xlC: 1501-218 file hello.CXX contains an incorrect file suffix
        xlC: 1501-218 file hello.CPP contains an incorrect file suffix
        xlC: 1501-218 file hello.CC contains an incorrect file suffix

It accepted the undocumented suffixes .cc, .cxx and .cpp, as well as

The FreeBSD gcc also seemed restrictive, so I tried other suffixes:

        hello.CXX: file not recognized: File format not recognized
        hello.CPP: file not recognized: File format not recognized
        hello.CC: file not recognized: File format not recognized

It accepted .cc, .cxx, .cpp, and .C.

The one major system missing from my tests is HP-UX; I have an account
on one, but ISO C and C++ compilers cost extra, and that particular
system doesn't have them.

Thus, .cpp seems pretty safe.  SGI's OCC seems the only one without
that support, and on our systems, it not longer runs:

        % OCC hello.cpp && ./a.out
        OCC ERROR:  OCC is not installed in /usr/lib32/cmplrs/OCC

It looks worthwhile to examine existing practice:

        In our source archives, I found 194 .tar* files from 65
        distinct packages with extension .cc.

        Only two packages (fam and glut) used .c++.

        I found 210 .tar* files from 75 distinct packages with
        extension .cpp.

        I found 3 .tar* files from 2 packages with extension .CC.

        I found 34 .tar* files with extension .cxx from 16 packages
        with extension .cxx.

        I found 37 .tar* files with extension .C from 19 packages with
        extension .C.

This might be a case for GNU standardization or at least recommended
practice: perhaps the issue should be raised with rms and, perhaps,
the gcc developers.

- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- Center for Scientific Computing       FAX: +1 801 581 4148                  -
- University of Utah                    Internet e-mail: address@hidden  -
- Department of Mathematics, 110 LCB        address@hidden  address@hidden -
- 155 S 1400 E RM 233                       address@hidden                    -
- Salt Lake City, UT 84112-0090, USA    URL:  -

reply via email to

[Prev in Thread] Current Thread [Next in Thread]