Any reason for that, what is .cc
for?
-
I believe the `cc` extensions comes from the time when C++ was **C** with **C** lasses. – Joe D Aug 28 '10 at 00:14
-
1possible duplicate of [Correct C++ code file extension? .cc vs .cpp](http://stackoverflow.com/questions/1545080/correct-c-code-file-extension-cc-vs-cpp) – Hans Passant Aug 28 '10 at 00:37
-
@Hans: And JaredPar has the #1 answer in both questions - though I'd argue that the answer here is slightly more informative and incorporates the essence of the answer in the other question... – Michael Burr Aug 28 '10 at 23:37
2 Answers
C++ is the ultimate language of choice and flexibility and C++ developers like to be different. The .cc extension is just one of the many that people choose for header and source files. Some others I've seen.
- No extension: Popular with header files
- .h
- .hpp
- .cpp
- .cc
- .c
- .C (explicit capital on case sensitive file systems)
- .cxx
- .inl (for inline templates)
Which to use is merely a matter of preference. There is no inherent gain from choosing one extension over the other.
The only real effect the extension has is to kill a team's productivity for a day or two while they debate the best one to use.

- 733,204
- 149
- 1,241
- 1,454
-
3Don't forget the capital-C extension (*.C) for C++, which of course will cause a bit of pain if you ever decide to move the project to a system like Windows, which doesn't see case as significant in filenames. – Michael Burr Aug 28 '10 at 00:16
-
1Though most uses have fallen by the way side of history and the most popular choice for c++ source is *.cpp (though historically some keep cropping up). – Martin York Aug 28 '10 at 00:23
-
3+1 for `only real effect the extension has is to kill a team's productivity for a day or two while they debate the best one to use.` =) – Rob Aug 28 '10 at 00:47
-
1`.c++` is a valid extension on most filesystems, but for some reason it's rarely used. – dan04 Aug 28 '10 at 00:49
I'm not aware for a deep reason for it other than that the string "c++" makes a poor extension on many OSes. :-) I believe these conventions developed before there was a standard, and because the language and compilers themselves generally don't ascribe any particular meaning to the extensions of the source files, no standard was ever necessary. .cc
might originally have been a reference to "C with Classes," but that's speculation on my part (and maybe Joe's).
.cc
, .cpp
, and .cxx
are all common extensions for C++ source files.

- 7,665
- 1
- 28
- 44
-
The compilers don't, but "make" does. On Solaris, if you have x.cc you can type "make x" and have a chance of getting an executable (depends on, well, dependencies - you may need explicit -I, -L, -l). FWIW, .cpp doesn't work (at least last time I checked, though I'm on Linux most of the time these days). – Tony Delroy Aug 28 '10 at 07:10