tags:

views:

117

answers:

2

Any reason for that, what is .cc for?

+10  A: 

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.

JaredPar
Don'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
Though 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
@Michael, thanks added that one.
JaredPar
+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
`.c++` is a valid extension on most filesystems, but for some reason it's rarely used.
dan04
@Martin: I would +1 if you didn't reference lolcats
Falmarri
@Martin: What do lolcats outside of the US use? SCNR.
sbi
+2  A: 

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.

Owen S.
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