GNU GCC recognises all of the following as C files, and will use C compilation regardless of whether you invoke it through gcc or g:.C,.cc,.cpp,.CPP,.c,.cp, or.cxx. Note the.C - case matters in GCC,.c is a C file whereas.C is a C file (if you let the compiler decide what it is compiling that is). GCC also supports other suffixes to indicate special handling, for example a.ii file will be compiled as C, but not pre-processed (intended for separately pre-processed code). All the recognised suffixes are detailed at. Great advice on which to use for the makefile and other tools, considering non-compiler tools while deciding on which extension to use is a great approach to help find an answer that works for you. I just wanted to add the following to help with some.cc vs.cpp info that I found.
The following are extensions broken down by different environments (from the 'C Primer Plus' book): Unix uses:.C,.cc,.cxx,.c GNU C uses:.C,.cc,.cxx,.cpp,.c Digital Mars uses:.cpp,.cxx Borland C uses:.cpp Watcom uses:.cpp Microsoft Visual C uses:.cpp,.cxx,.cc Metrowerks CodeWarrior uses:.cpp,.cp,.cc,.cxx,.c The different environments support different extensions. I too was looking to answer this question and found this post. Dopamine maca. Based on this post I think I might go with.hpp and.cpp for ease of cross-platform/cross-tool recognition.
I personally use.cc extension for implementation files,.hh for headers, and.inl for inline/templates. As said before, it is mainly a matter of taste. From what I've seen,.cc seems to be more ' open source projects oriented', as it is advised in some great open source software coding styles, whereas. Cpp seems to be more Windowish. EDIT As mentioned, this is 'from what i've seen', it may be wrong. It's just that all Windows projects I've worked on used.cpp, and a lot of open source projects (which are mainly on unix-likes) use.cc. Examples coding styles using.cc:.
Google:. ICL.
Several people saying.cc doesn't stand for anything? C started life as 'C with Classes'. True that.cc and.cpp are also command names on most Unix systems (c compiler and c preprocessor respectively). I use.cpp exclusively, but I started on Windows.cc is more a Unix convention, although I see it less and less even there.
GNU make has rules for.cpp so that's probably preferred, it will work by default on both Windows and everything else. On the other hand modern C uses no extension at all for headers, I really don't like that. All my projects use.h for header files, and they support both C and C as much as possible via extern 'C' and testing cplusplus.C and.cc seem to be standard for the (few) Unix-oriented C programs I've seen. I've always used.cpp myself, since I only really work on Windows and that's been the standard there since like forever.
I recommend.cpp personally, because. It stands for 'C Plus Plus'. It is of course vitally important that file extensions are acronyms, but should this rationale prove insufficiently compelling other important things are non-use of the shift key (which rules out.C and.c) and avoidance of regular expression metacharacters where possible (which rules out.c - unfortunately you can't really avoid the. This doesn't rule out.cc, so even though it doesn't really stand for anything (or does it?) it is probably a good choice for Linux-oriented code.