Comments on DMD frontend.

Bill Baxter dnewsgroup at billbaxter.com
Thu Feb 28 13:56:35 PST 2008


Julio César Carrascal Urquijo 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.
>>
>> Calling it "commonly used" is a stretch.
>>
>> But I think that being a "barrier to contributors" is a stretch as 
>> well.  File naming pales in comparison to the other barriers that exist.
>>
>> --bb
> 
> 
> Not as uncommon as I though:
> 
> http://www.google.com/codesearch?q=file%3A%5C.c%24+%3A%3A
> 
> There's a lot of C++ code using the .c extension. Specially from Mozilla 
> and the W3C.

That's a good idea for a search string, but most of those hits have the 
'::' in a comment, and if you go look at the actual source files, they 
are indeed plain C code.

There's another one that's a SWIG-generated wrapper that looks like it's 
meant to be able to compile as either C or C++.

It would be quite surprising if Mozilla contained lots of C++ files 
named .c, since their own portability guide says this:
http://developer.mozilla.org/en/docs/C%2B%2B_Portability_Guide#C.2B.2B_filename_extension_is_.cpp

The hit in Xerces appears to be a real C++ file using .c.  However it 
seems to be an anomoly.  If you go look at the full source tree, you 
find that it's the only one.
   http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/
All the other files in that dir are using .cpp or .hpp

The STLport code is a good real example, though.  Big high-profile 
project, and the latest source tree has a slew of C++ files called .c.
   http://stlport.cvs.sourceforge.net/stlport/STLport/stlport/stl/
HOWEVER, those are all nothing but templates.  You have to #include them 
(or rather they get #included for you via some chain of #includes when 
you say #include <vector>).  So really what they are is header files 
with a .c extension.  There's not really a problem with naming header 
files whatever you want to name them, since compilers don't have to 
guess what type they are.  Other, non-header C++ files in the STL tree 
seem to be named .cpp.

--bb



More information about the Digitalmars-d mailing list