In message <53064p@netlab.cs.rpi.edu>, I called for a survey on which extensions people were using on their C++ source code
This web page holds the results of the survey, in the form of HTML 3.2 tables. If you don't have a browser that supports tables (e.g. W3-mode), these pages probably aren't worth much to you. However, I don't really have the time to do text formatting of this information... Sorry!
Header extension | Source extension | WHY | Borland C++, Win16 | Borland C++, Win16, Win32 | Borland C++, Win32 | Borland C++, Windows | Borland C++,Win16 | Borland, Win32, Win16, DOS | Centerline, Solaris 20 | DEC C++, Digital Unix 32 | GCC 272/Libg++ 271, Linux | GCC, IRIX 53 | GCC, Linux | GNU C++, Linux | GNU C++, Solaris 1x | GNU, DOS | GNU, VxWorks | HP C compiler/linker/xclearcase, HP-UX 10 | HP-CC, HP-UX | HP-UX 901, HP-UX 1010 | IBM Visual Age C++ 30, OS/2 Warp | IRIX 405, IRIX 53 | IRIX 62 | Intel 80x86 | Metrowerks C++, Mac | Metrowerks Code Warrior, MacOS | Metrowerks CodeWarrior, MacOS | Metrowerks CodeWarrior, Win32 | Metrowerks Codewarriour, MacOS | Metrowerks, Macintosh | Microsoft Visual C++, Win16 | Microsoft Visual C++, Win32 | OSCC, SunOS 41 | SPARCWorks 41, Solaris 24 | SPARCWorks 41, Solaris 25 | Solaris 24 | Sun CC 41, Solaris 25 | Symantec C++ 721, Win32 | Symantec, Macintosh | VC++, Win32 | Visual C++, Win32 | Visual/C++, Win16 | Visual/C++, Win32 | Visual/C++, Win32 | Visual/C++, Win95, WinNT | Watcom C++,Win16 | Watcom, OS2 | all | gcc, Linux | gcc, SunOs 4 | vi/sh,HP-UX 9x |
h | cc | 'h' because they're Header files. 'cc' because 'cpp' belongs to the C language preprocessor and because I don't like 'c++' | X | X | X | ||||||||||||||||||||||||||||||||||||||||||||||
h | cpp | Because that's what Microsoft does and they rule the world. | X | ||||||||||||||||||||||||||||||||||||||||||||||||
hh | cc | no specific reason | X | ||||||||||||||||||||||||||||||||||||||||||||||||
h | cpp | Need to distinguish c from c++ sources so that the IDE canautomatically distinguish between c & c++ files. Chose "cpp" because if you asked any moron what a three-letter acronym for "C plus plus" was, they would say "cpp". C & C++ includes don't need to be distinguished from one another since they're only used "manually", by someone's explicit include directive. All C includes are bracketed with #ifdef __cplusplus \ extern "C" { \ etc. | X | X | X | X | X | ||||||||||||||||||||||||||||||||||||||||||||
h | cpp | I like cpp because that is what I'm used to. I would ratheruse .hpp for C++ headers and .h for C compatible headers, but .h seems to be the "standard" in the Win32 world right now. | X | ||||||||||||||||||||||||||||||||||||||||||||||||
h | cc | We wanted something that would work on both Solaris and Windowsplatforms, and would be case-insensitive. We didn't think it was important to distinguish C++ and C header files. | X | X | X | X | |||||||||||||||||||||||||||||||||||||||||||||
none | cpp | only common source extension that works with both environments (wecouldn't get Microsoft Visual C++ to accept .cp source files). Some of our files still have .cp extensions, so when they are transferred to Microsoft Visual C++, a script renames them to .cpp. | X | X | X | ||||||||||||||||||||||||||||||||||||||||||||||
h | cpp | It is the most consistantly allowed extentions in the default"open file" dialog boxes across the compilers I have used, including MSVC, Watcom, and Borland. | X | X | |||||||||||||||||||||||||||||||||||||||||||||||
h | cc | We have to include C header files occationally, using .h for all include file is just easier. For source files, well, relying on case may cause trouble in some environments, and so may non alphabetic characters so that rules out .C and .c++. .cpp leads the mind to the C preprocessor. This leaves us with .cc. | X | X | |||||||||||||||||||||||||||||||||||||||||||||||
hxx | cxx | X | X | ||||||||||||||||||||||||||||||||||||||||||||||||
hh | cxx | X | |||||||||||||||||||||||||||||||||||||||||||||||||
h | C | Because of the Style Guide -- MfG/Bye/Udv - Simon Istvan - mailto:simo@ws6a37.gud.siemens.co.at - -- hint: my last name is my first name :-) -------------------------- "You can demonstrate a program for a corporate executive, but you can't make him computer literate." | X | ||||||||||||||||||||||||||||||||||||||||||||||||
h | cpp | None of the compilers really cared; these extensions were incommon use in other projects and there was no reason to change. | X | X | X | ||||||||||||||||||||||||||||||||||||||||||||||
cpp | |||||||||||||||||||||||||||||||||||||||||||||||||||
h | cpp | any environment undertand what to do with cpp files | X | X | |||||||||||||||||||||||||||||||||||||||||||||||
h | C | Stroustrup uses it. | X | X | |||||||||||||||||||||||||||||||||||||||||||||||
hpp | cpp | No one set of suffixes is accepted (as meaning "this file is C++")by all three compilers; CPP/HPP is accepted by Symantec and IBM (for GCC I need to use -x c++). | X | X | X | ||||||||||||||||||||||||||||||||||||||||||||||
h | cpp | CPP because it was the only extention I'd heard of for years and years. H because the ones for C headers are almost trivially compatible with C++, C++ headers are trivially rejected by C compilers, and because experience with the use of P as the extention for files that contained prototypes (only) of C functions was not happy experience. | X | X | |||||||||||||||||||||||||||||||||||||||||||||||
h | cpp | I began using this format with (Borland) Turbo C++ as it was thedefault extensions when I made source files. I have had no problems with this particular format on my platform ever since. | X | X | |||||||||||||||||||||||||||||||||||||||||||||||
h | cpp | The tools we use, prefer it. | X | ||||||||||||||||||||||||||||||||||||||||||||||||
h | cpp | Well, "cp" seemed kind of silly. If were going to accept the name"C++" (which is also silly) why not use "cpp"? I'd prefer "c++", which the Mac would be OK with, but 16-bit MS Windows certainly doesn't like it. "C" can be problematic since both the MacOS and MS Windows have case-insensitive file systems. "cc" just doesn't make any sense to me. For header files I've never had the need to distinguish, but I can see cases where it might be necessary. If I didn't use "h", I'd use whatever was parallel to what I was using for source files. | X | X | X | X | X | X | X | ||||||||||||||||||||||||||||||||||||||||||
h | cc | UNIX is the main target, so others make due. | X | ||||||||||||||||||||||||||||||||||||||||||||||||
hxx | cxx | So editors and makefiles can distinguish between c and c++ headers,.hxx is used rather than .h. Reasons for .cxx are as follows: 1. .c vs .C is no use on some platforms which are case insensitive. 2. .c is no use so compilers and editors can distinguish between C and C++ 3. anything longer than 3 chars is no use on windows/VMS systems. 4. cpp is sometimes used for c preprocessor output. 5. c++ is no use as many platforms cannot support that suffix 6. yxx, lxx, can be used for yacc and lex, txx and ixx for templates and inline function files respectively. 7. If you use cxx rather than cc you can search in a directory (on UNIX) for *x, *xx or even *.?xx to find all your C++ related files (see point 6 above), this is not possible with the .cc style. As you can see, I have a slight preference for cxx over cpp. | X | ||||||||||||||||||||||||||||||||||||||||||||||||
h | cc | you need only one finger, unlike with .cpp or .C | X | ||||||||||||||||||||||||||||||||||||||||||||||||
hpp | cpp | c, h, C, H can not be distinguished from C sources/headers. Cpp wasused by Borland and Metrowerks as the default. | X | X | X | X | |||||||||||||||||||||||||||||||||||||||||||||
hh | cc | X | X | ||||||||||||||||||||||||||||||||||||||||||||||||
cc | |||||||||||||||||||||||||||||||||||||||||||||||||||
H | C | HP's CC compiler requires the .C; I use .H for parallelism andto distinguish from c-style .h. I use FT for template class member function definitions. | X | ||||||||||||||||||||||||||||||||||||||||||||||||
C | |||||||||||||||||||||||||||||||||||||||||||||||||||
hh | cc | I use cc because it's portable (C is indistinguishable from c inMS-DOS, and difficult to distinguish in UN*X, c++ doesn't work in DOS) and unique (cpp still means C Pre-Processor to me). cxx is an anathema -- I suppose it's supposed to represent c++ with the '+' signs leaning on their sides, but it looks stupid. I use hh to consistent with cc, although headers that are intended to be used in both C and C++ get the h extension -- and extern "C" in C++ -=Dave I can barely speak for myself, so I surely can't speak for B-Tree |==================================================================| | Dave Hansen | B-Tree Verification Systems, Inc. | | dhansen@btree.com | 5929 Baker Rd, Suite 475 | | (VOICE) 612-930-4112 | Minnetonka, MN 55345-5955 | | (FAX) 612-936-2187 | | |==================================================================| | X | X | X | ||||||||||||||||||||||||||||||||||||||||||||||
hh | cc | Our initial development was done using gcc on SunOs 4. When we portedto windows, we just created appropriate rules in our makefiles to handle "cc" and have had no problems. Given the ease of handling this in makefiles, I don't think the extension matters, as long as you are consistent. | X | X | X |
Header extension | Number: | Percentage: |
(missing response) | 3 | 10% |
H | 1 | 3% |
h | 17 | 55% |
hh | 5 | 16% |
hpp | 2 | 6% |
hxx | 2 | 6% |
none | 1 | 3% |
Source file extension | Number: | Percentage: |
(missing response) | 4 | 13% |
C | 3 | 10% |
cc | 9 | 29% |
cpp | 13 | 42% |
cxx | 2 | 6% |
Total number of responses: 31