garvey@johnny5.uucp (Joe Garvey) (06/14/91)
I'm just learning to program in C++ via G++. It seems there are different convensions for naming programs. GNU's libg++ has *.hP and *.ccP extensions. There also seems to be a school of thought to follow the standard C naming convensions. I assume this is to make tools like make(1) use C++ files without any hassle of defining new rules. B. Stroustrup's book follows this pattern. Could someone help me out here. I'm a little lost on how I should name files. Could someone also describe the reasoning behind the naming convensions if there is any. Thanks. -- Joe Garvey uucp: sumax!quick!johnny5!garvey J5 Research internet: quick!johnny5!garvey@sumax.seattleu.edu Bothell, Wa., 98021 AT&T: 206-481-8023
hargrove@asc.slb.com (Jim Hargrove) (06/14/91)
I don't know if our rules are the best, but here is the scheme we are
using:
Type of File Extension
C Source .c
C++ Source .cc
C Headers .h -- These may be used in C or C++
C++ Headers .hh -- These may not be used in C.
Some other plans we rejected were these:
C++ Source .C -- Works only on systems that use case
sensitive file names. DOS and VMS don't.
C++ Includes .H -- Ditto
C++ Source .cpp This is OK and widely used. Takes one
more character, more typing.
You need to distinguish between C and C++ files so you can run the C++
compiler on the latter. Of course, you can use the C++ compiler on C
files, but this is sometimes less efficient.
You need to be able to distinguish between include files that require
C++ to make sure these aren't included into a C program.
In a sense, this is a temporary problem. When C++ becomes more
prevalent, we will probably just have a single kind of filename.
Today, though, we have tons of old software in C coexisting with new
software in C++. The scheme above lets us sort this out automatically.
--
-- jwh