Updated: 1996-10-22 9:16 met dst, by sb

C++ source code extension survey

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!

List of tables:


All survey entries

Header extensionSource extensionWHY                                        Borland C++, Win16Borland C++, Win16, Win32Borland C++, Win32Borland C++, WindowsBorland C++,Win16Borland, Win32, Win16, DOSCenterline, Solaris 20DEC C++, Digital Unix 32GCC 272/Libg++ 271, LinuxGCC, IRIX 53GCC, LinuxGNU C++, LinuxGNU C++, Solaris 1xGNU, DOSGNU, VxWorksHP C compiler/linker/xclearcase, HP-UX 10HP-CC, HP-UXHP-UX 901, HP-UX 1010IBM Visual Age C++ 30, OS/2 WarpIRIX 405, IRIX 53IRIX 62Intel 80x86Metrowerks C++, MacMetrowerks Code Warrior, MacOSMetrowerks CodeWarrior, MacOSMetrowerks CodeWarrior, Win32Metrowerks Codewarriour, MacOSMetrowerks, MacintoshMicrosoft Visual C++, Win16Microsoft Visual C++, Win32OSCC, SunOS 41SPARCWorks 41, Solaris 24 SPARCWorks 41, Solaris 25Solaris 24Sun CC 41, Solaris 25Symantec C++ 721, Win32Symantec, MacintoshVC++, Win32Visual C++, Win32Visual/C++, Win16Visual/C++, Win32Visual/C++, Win32 Visual/C++, Win95, WinNTWatcom C++,Win16Watcom, OS2allgcc, Linuxgcc, SunOs 4vi/sh,HP-UX 9x
hcc'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        
hcppBecause that's what Microsoft does and they rule the world.                                      X          
hhccno specific reason                     X                            
hcppNeed 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        
hcppI 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        
hccWe 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      XX       
nonecpponly 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          
hcppIt 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    
hccWe 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                  
hxxcxx                X                     X          
hhcxx                                  X              
hCBecause 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                                 
hcppNone of the compilers really cared; these extensions were incommon use in other projects and there was no reason to change.          XX                             X        
cpp                                                 
hcppany environment undertand what to do with cpp files    X                  X                          
hCStroustrup uses it.             X                   X                
hppcppNo 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             
hcppCPP 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           
hcppI 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      
hcppThe tools we use, prefer it.                                        X        
hcppWell, "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                     XX  XX        X          
hccUNIX is the main target, so others make due.                                              X   
hxxcxxSo 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               
hccyou need only one finger, unlike with .cpp or .C                                               X  
hppcppc, h, C, H can not be distinguished from C sources/headers. Cpp wasused by Borland and Metrowerks as the default. XX         X              X                      
hhcc    X                                      X     
cc                                                 
HCHP'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                                                 
hhccI 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      XX                                  
hhccOur 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.                                        XX      X 

Header extensions summary

Header extensionNumber: Percentage: 
(missing response)310% 
H13% 
h1755% 
hh516% 
hpp26% 
hxx26% 
none13% 

Source file extensions summary

Source file extensionNumber: Percentage: 
(missing response)413% 
C310% 
cc929% 
cpp1342% 
cxx26% 

Total number of responses: 31