Naming C++ files

Bill Baxter dnewsgroup at billbaxter.com
Wed Feb 27 23:36:42 PST 2008


Walter Bright wrote:
> Bill Baxter wrote:
>> You gotta be kidding.  I've seen lots of extensions used for C++ code, 
>> but never .c.
>> file.cpp, file.cc, file.C, file.CC, file.cxx, file.c++, file.C++, yes 
>> yes and yes.
>> But never file.c.
> 
> All I can say is, I have. That's why dmc has a switch to treat .c files 
> as C++ source, and it has had that switch pretty much from the beginning 
> (20 years ago), from long before I gave up on using .cpp.

My experience only goes back to 10 years.  It makes some sense that 
people would be using .c back at the very beginnings of C++.  Especially 
given that Stroustrup didn't specify what the extension should be, and 
from what I understand he started out just with the intention of making 
C easier to use by adding classes.  The initial implementations were 
just fancy preprocessors that generated C code, so it makes sense that 
the extension then would still be .c.  They don't call Qt source code 
files .qt just because you have to run that moc preprocessor on them, 
after all.


>> Calling it "commonly used" is a stretch.
> 
> C++, from day 1, never standardized on an extension. If it had, this 
> discussion would be moot.

Indeed.  Could have saved a lot of headaches over the years if there had 
been one.   .cpp is my personal favorite.  :-)

--bb



More information about the Digitalmars-d mailing list