File Extension?
73
u/Markus_included May 25 '23
.cc => You probably work for google
.cxx => Don't know, i've only seen in it the FLTK repo
.cpp => Congratulations, you're 90% C++ programmers
.c++ => You probably, use spaces in filenames
.C => Welcome to the future time traveler from the year 198524
u/OverLiterature3964 May 25 '23
Using spaces in filenames... ew
33
18
u/pjmlp May 25 '23
I guess I am just old.
.cxx, .c++ and .C were common in commercial UNIX during the last century.
By the way, you forgot the .hpp, .h++ and .H variants that go along with them.
7
1
u/ramennoodle May 25 '23
.cpp came later but it was Microsoft's choice so...
3
u/pjmlp May 26 '23
Microsoft had nothing to do with it, in fact Microsoft was the last compiler vendor to add C++ support to their MS-DOS C compiler with the release of Microsoft C/C++ 7.0.
1
u/Questioning-Zyxxel May 25 '23
cpp existed at the same time as c++ and cxx. I got to use all three a very, very, very long time ago on Sun machines. Somehow I managed to avoid the *.C and *.H names.
Moving to MS-DOS, *.c++ was obviously not a hot contender. So most of my code ended up *.cpp or *.cc (given that I also jumped in and out of v0.96 Linux dual-booted until I got my 3rd PC)
46
u/nihilistic_ant May 25 '23
More controversial is .h vs .hpp for headers
30
u/War_Eagle451 May 25 '23
I'm .hpp all the way. For 2 main reasons. First, it's consistent with .cpp. Second, my brain tells me that 3/4 letter extensions look better
5
3
u/nihilistic_ant May 25 '23 edited May 25 '23
Although the core guidelines say to prefer .h.
[edit: FWIW, I lean your direction; my current personal projects use hpp.]
8
5
5
4
u/GregTheMadMonk May 25 '23
.hh, naturally. Goes well with.cc1
u/wrosecrans graphics and network things May 26 '23
.hcso you know it's a "Header for C++" and not a header for Fortran or C or Cobol or whatever.2
2
u/donalmacc Game Developer May 25 '23
My IDE generates h files - I don't think about it any more than that.
7
-2
u/foghatyma May 25 '23
.h: when the interface and implementation is separated
.hpp: when the implementation is also in the header file, e.g. template classes (hpp = h + cpp)0
May 25 '23
[deleted]
18
u/be-sc May 25 '23
I go one step further. Accidentally valid C headers aren’t sufficient for the .h suffix. The header must be part of the program’s intentional C API. If not, it’s .hpp.
10
9
5
4
6
u/ImKStocky May 25 '23
.ixx because that is the default file extension for modules in MSVC
3
u/pjmlp May 25 '23
We still need cpp as well, though.
2
u/Kelarov May 25 '23
That's it.
.cppand.ixxis all I use now haha. No more freaking header files haha1
u/Baardi Jul 07 '23
I wish they went with .ipp or something, instead. Less of a change from the .cpp/.hpp norm.
1
u/Kelarov Jul 07 '23
Sure. And I'd be fine with
.cppmas well haha. I mentioned.ixxbecause MSVC is the only compiler that plays OK with Modules(I've been literally, exclusively using MSVC) and having.ixxkinda helps the environment, since that's what Microsoft thinks the Modules' File Extension should be haha.1
2
u/ImKStocky May 25 '23
A singular one for main Vs the rest of the project which is .ixx
1
u/pjmlp May 25 '23
Depends how much you want to recompile the related projects due to changes in private parts, and if you're using partitions.
Right now, even VC++ being the best implementation available, it isn't clever enough to avoid recompilation.
4
u/ChocolateMagnateUA May 25 '23
I use .cc and correspondly .hh because it sounds like "C with Classes," and while I understand this is not true, this extension symbolises unification of abstraction and rawness and that's what my relation to C++ is. You are also right that I am immersed into the Google ecosystem, I even use Bazel instead of Cmake, so better for me.
3
3
May 25 '23
Does anyone actually use .c++
3
2
u/GLIBG10B 🐧 Gentoo salesman🐧 May 25 '23
Does Windows even allow that? I wouldn't be surprised if it didn't
5
1
1
u/spam_bot42 May 27 '23
I was using .cpp for a long time but switched to .cc in a new project because it's consistent with other extensions there, like .ll and .yy. (for c++ flex and bison)
1
1
0
0
0
0
94
u/pdp10gumby May 25 '23
Didn’t we settle this question in this very sub a few months ago?
iirc it was
.C-plus-Plus_implementationand.C-plus-Plus_Interface