www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Comments on DMD frontend.

reply Leandro Lucarella <llucax gmail.com> writes:
Hi. I'm starting to play arround with the DMD frontend bundled with the
compiler.

My firt big surprise, and not a good one, was that the frontend files are
named with the .c extension, instead of .cpp, .cxx, or anything used for
C++ files. Is there a rationale behind that? I find it very confusing.

Second, I saw the code has a lot of:
#if DEBUG
printf(...);
#endif

(LOG or simply 0 are used too)

This is really annoying and can easily be changed for something like:
#if DEBUG

#else

#endif

(I know macros with variable arguments are just in C99, but I think most
compilers has a vendor-specific way of doing it)

And then just write: debug(...);

This makes the code much more readable.

In some places there's a sightly more complicated:
#if DEBUG
if (condition)
	printf(...);
#endif

which can be solved by adding a new macro, for example "cdebug" (c for
conditional):

#if DEBUG

#else

#endif

And just writing: cdebug(condition, ...);

If you are willing to accept a patch that implement this, I'm willing to
do it.

And please, can you please, please consider on putting the frontend on a
SCM? (git would be great, dsource's svn is ok :).

Thanks!

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Fitter, happier, more productive, comfortable, not drinking too much,
regular exercise at the gym (3 days a week),
getting on better with your associate employee contemporaries,
Feb 23 2008
next sibling parent Robert Fraser <fraserofthenight gmail.com> writes:
Leandro Lucarella wrote:
 [...]
If it helps at all (it probably doesn't...) there's a port of the entire front-end from C++ to Java in Descent: http://www.dsource.org/projects/descent/browser/trunk/descent.core/src/descent/internal/compiler/parser
Feb 23 2008
prev sibling next sibling parent reply "Janice Caron" <caron800 googlemail.com> writes:
On 24/02/2008, Leandro Lucarella <llucax gmail.com> wrote:
  This is really annoying and can easily be changed for something like:
  #if DEBUG

  #else

  #endif

  (I know macros with variable arguments are just in C99, but I think most
  compilers has a vendor-specific way of doing it)
You can do it without varags. #if DEBUG #else #endif So long as you're prepared to call it like this: dprintf(("Error on line %d",n)); My favorite C trick, though, was always: #ifdef DEBUG #else #endif Then you do debug printf(whatever); which resolves to printf(whatever); in debug mode, but to // printf(whatever); in release mode. Now "debug" works almost like in D. Yes, I know, technically C doesn't support // comments, but I've never yet encountered a compiler that doesn't understand them. (I still have to write C sometimes, professionally). I don't care what language the D compiler is written in, as long as it works. (Although now that D1 is stable, it would be quite cool to rewrite it in that).
Feb 24 2008
next sibling parent reply Leandro Lucarella <llucax gmail.com> writes:
Janice Caron, el 24 de febrero a las 08:52 me escribiste:
 On 24/02/2008, Leandro Lucarella <llucax gmail.com> wrote:
  This is really annoying and can easily be changed for something like:
  #if DEBUG

  #else

  #endif

  (I know macros with variable arguments are just in C99, but I think most
  compilers has a vendor-specific way of doing it)
You can do it without varags. #if DEBUG #else #endif So long as you're prepared to call it like this: dprintf(("Error on line %d",n));
Yes, but that's a little more uglier and error prone, so if DMC supports varargs (I can't test it because I don't have Windows, and I can't find a DMC download for Linux), I'll defenetly go with varargs.
 My favorite C trick, though, was always:
 
     #ifdef DEBUG

     #else

     #endif
 
 Then you do
 
     debug printf(whatever);
 
 which resolves to
 
     printf(whatever);
 
 in debug mode, but to
 
     // printf(whatever);
This is a clever trick but IMHO it's a little confusing too.
 in release mode. Now "debug" works almost like in D. Yes, I know,
 technically C doesn't support // comments, but I've never yet
 encountered a compiler that doesn't understand them.
That's probably because // comments are valid C99 =) -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------------- Sus descipulos se miraron, sin entender unos a otros y uno levantó su manito y le dijo: Peperino, Peperino, soy Antonito de capital: y tengo un salvavidas... a lo que Peperino, lo miró, lo tocó, lo frotó y lo sanó. Y todos dijeron: ehhh! Peperino se la come! Peperino se la come! -- Peperino Pómoro
Feb 24 2008
parent Walter Bright <newshound1 digitalmars.com> writes:
Leandro Lucarella wrote:
 This is a clever trick but IMHO it's a little confusing too.
I've used those debug macros in various forms in other projects. Over time, I just gradually swung back to using the more straightforward #if method. This also has evolved into the 'debug' conditional compilation present in D.
Feb 24 2008
prev sibling parent reply DBloke <DBloke nowhere.org> writes:
 (I still have to write C sometimes, professionally).
Nowt wrong with C :) especially back end stuff and the like, sadly C got its bad name from trying to be an all things to all people language and even today there is no such thing as a one language fits all as far as I know, but D comes pretty darned close :)
 
 I don't care what language the D compiler is written in, as long as it
 works. (Although now that D1 is stable, it would be quite cool to
 rewrite it in that).
An interesting idea ;), and probably an excellent example of the power of D?
Feb 24 2008
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"DBloke" <DBloke nowhere.org> wrote in message 
news:fps39f$1mfs$1 digitalmars.com...
 (I still have to write C sometimes, professionally).
Nowt wrong with C :) especially back end stuff and the like, sadly C got its bad name from trying to be an all things to all people language and even today there is no such thing as a one language fits all as far as I know, but D comes pretty darned close :)
 I don't care what language the D compiler is written in, as long as it
 works. (Although now that D1 is stable, it would be quite cool to
 rewrite it in that).
An interesting idea ;), and probably an excellent example of the power of D?
See Dil: http://code.google.com/p/dil/ It's already got the lexing and parsing done, as well as a better DDoc generator than the DMDFE. And it's written entirely in D1.
Feb 24 2008
next sibling parent Jascha Wetzel <firstname mainia.de> writes:
Jarrett Billingsley wrote:
 See Dil: http://code.google.com/p/dil/
 
 It's already got the lexing and parsing done, as well as a better DDoc 
 generator than the DMDFE.  And it's written entirely in D1. 
alternatively see http://seatd.mainia.de :) which is D1, too lexing, parsing, semantics growing steadily
Feb 24 2008
prev sibling parent DBloke <DBloke nowhere.org> writes:
 See Dil: http://code.google.com/p/dil/
 
 It's already got the lexing and parsing done, as well as a better DDoc 
 generator than the DMDFE.  And it's written entirely in D1. 
 
Looking good, D has some excellent programs out there but could really use a killer app to show off to the world.
Feb 24 2008
prev sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Leandro Lucarella wrote:
 My firt big surprise, and not a good one, was that the frontend files are
 named with the .c extension, instead of .cpp, .cxx, or anything used for
 C++ files. Is there a rationale behind that? I find it very confusing.
When I first started with C++, I carefully named all my h files ".hpp" and source files ".cpp". Over time, the .hpp was dropped in favor of .h, and eventually .cpp => .c. It's not confusing to me because I never mix C and C++ source files in the same project.
Feb 26 2008
next sibling parent reply Alexander Panek <alexander.panek brainsware.org> writes:
Walter Bright wrote:
 Leandro Lucarella wrote:
 My firt big surprise, and not a good one, was that the frontend files are
 named with the .c extension, instead of .cpp, .cxx, or anything used for
 C++ files. Is there a rationale behind that? I find it very confusing.
When I first started with C++, I carefully named all my h files ".hpp" and source files ".cpp". Over time, the .hpp was dropped in favor of .h, and eventually .cpp => .c. It's not confusing to me because I never mix C and C++ source files in the same project.
Well, but other people might look at your sources the first time, not knowing what language those are actually written in.. Consistency is one of the good measurements for product quality.
Feb 26 2008
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Alexander Panek wrote:
 Walter Bright wrote:
 Leandro Lucarella wrote:
 My firt big surprise, and not a good one, was that the frontend files 
 are
 named with the .c extension, instead of .cpp, .cxx, or anything used for
 C++ files. Is there a rationale behind that? I find it very confusing.
When I first started with C++, I carefully named all my h files ".hpp" and source files ".cpp". Over time, the .hpp was dropped in favor of .h, and eventually .cpp => .c. It's not confusing to me because I never mix C and C++ source files in the same project.
Well, but other people might look at your sources the first time, not knowing what language those are actually written in.. Consistency is one of the good measurements for product quality.
But Walter just said he's consistent about it! Too consistent -- always .c no matter what. It's consistent, it just doesn't conform with standard practices. --bb
Feb 26 2008
prev sibling parent reply Leandro Lucarella <llucax gmail.com> writes:
Walter Bright, el 26 de febrero a las 12:24 me escribiste:
 Leandro Lucarella wrote:
My firt big surprise, and not a good one, was that the frontend files are
named with the .c extension, instead of .cpp, .cxx, or anything used for
C++ files. Is there a rationale behind that? I find it very confusing.
When I first started with C++, I carefully named all my h files ".hpp" and source files ".cpp". Over time, the .hpp was dropped in favor of .h, and eventually .cpp => .c. It's not confusing to me because I never mix C and C++ source files in the same project.
It's not confusing to you! If you do it in a closed source project, it's perfectly fine but if you do it in an open source project, it's a bad thing (TM). You are putting a barrier to people to contribute (and making D look ugly). What are the chances that you rename them to a commonly used C++ extension? And what about the debug stuff. Are you willing to accept patcher or not? I'm just looking for a "yes" or "no". Please? Thank you. -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------------- MP: Cómo está, estimado Bellini? B: Muy bien, Mario, oraculizando. MP: Qué tengo? B: El auto mal estacionado. MP: No, en mi mano, Bellini... B: Una murga! MP: No, escuche bien. Es de lona. B: Un ring, Mario. MP: No Bellini. Tiene cordones. B: La vereda. MP: No Bellini! Muy fácil, eh! Es B: Una modelo, Mario! imprescindible para jugar al B: Un negro, Mario. basquet. MP: No, Bellini, no y no! -- El Gran Bellini (Mario Podestá con unas zapatillas de basquet)
Feb 27 2008
next sibling parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Leandro Lucarella wrote:
 Walter Bright, el 26 de febrero a las 12:24 me escribiste:
 Leandro Lucarella wrote:
 My firt big surprise, and not a good one, was that the frontend files are
 named with the .c extension, instead of .cpp, .cxx, or anything used for
 C++ files. Is there a rationale behind that? I find it very confusing.
When I first started with C++, I carefully named all my h files ".hpp" and source files ".cpp". Over time, the .hpp was dropped in favor of .h, and eventually .cpp => .c. It's not confusing to me because I never mix C and C++ source files in the same project.
It's not confusing to you! If you do it in a closed source project, it's perfectly fine but if you do it in an open source project, it's a bad thing (TM). You are putting a barrier to people to contribute (and making D look ugly). What are the chances that you rename them to a commonly used C++ extension? And what about the debug stuff. Are you willing to accept patcher or not? I'm just looking for a "yes" or "no". Please? Thank you.
Additionally, some IDEs decide what compiler to use based on the filename extension and will automatically try to use a C compiler instead of a C++ one if the filename is .c. It doesn't matter for headers to be called .h since they're not directly compiled. (Even with pre-compiled headers you pre-compile them by #including them all in a single source file). Also editors often decide on what syntax highlighting mode to use based on the extension. So it's not just about people getting confused. --bb
Feb 27 2008
prev sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Leandro Lucarella wrote:
 It's not confusing to me because I never mix C and C++ source files in the
same project.
It's not confusing to you! If you do it in a closed source project, it's perfectly fine but if you do it in an open source project, it's a bad thing (TM). You are putting a barrier to people to contribute (and making D look ugly). What are the chances that you rename them to a commonly used C++ extension?
.c is a commonly used C++ extension, but I understand your point. I'd also rather not change it, as it's an admittedly personal preference.
 And what about the debug stuff. Are you willing to accept patcher or not?
 I'm just looking for a "yes" or "no". Please?
Not for just altering the debug print statements, again, it's a personal preference.
Feb 27 2008
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Walter Bright wrote:
 Leandro Lucarella wrote:
 It's not confusing to me because I never mix C and C++ source files 
 in the same project.
It's not confusing to you! If you do it in a closed source project, it's perfectly fine but if you do it in an open source project, it's a bad thing (TM). You are putting a barrier to people to contribute (and making D look ugly). What are the chances that you rename them to a commonly used C++ extension?
.c is a commonly used C++ extension, but I understand your point. I'd also rather not change it, as it's an admittedly personal preference.
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
Feb 27 2008
next sibling parent reply Robert Fraser <fraserofthenight gmail.com> writes:
Bill Baxter wrote:
 Walter Bright wrote:
 Leandro Lucarella wrote:
 It's not confusing to me because I never mix C and C++ source files 
 in the same project.
It's not confusing to you! If you do it in a closed source project, it's perfectly fine but if you do it in an open source project, it's a bad thing (TM). You are putting a barrier to people to contribute (and making D look ugly). What are the chances that you rename them to a commonly used C++ extension?
.c is a commonly used C++ extension, but I understand your point. I'd also rather not change it, as it's an admittedly personal preference.
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
When I took my first class that introduced C and C++ programming, the professor said that ".c" was the only standardized extension for C++ files, and that ".cpp",".cc", and ".cxx" were nonstandard and shouldn't be used.
Feb 27 2008
next sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Robert Fraser wrote:
 Bill Baxter wrote:
 Walter Bright wrote:
 Leandro Lucarella wrote:
 It's not confusing to me because I never mix C and C++ source files 
 in the same project.
It's not confusing to you! If you do it in a closed source project, it's perfectly fine but if you do it in an open source project, it's a bad thing (TM). You are putting a barrier to people to contribute (and making D look ugly). What are the chances that you rename them to a commonly used C++ extension?
.c is a commonly used C++ extension, but I understand your point. I'd also rather not change it, as it's an admittedly personal preference.
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
When I took my first class that introduced C and C++ programming, the professor said that ".c" was the only standardized extension for C++ files, and that ".cpp",".cc", and ".cxx" were nonstandard and shouldn't be used.
Weird. I mean I don't even think Stroustrup's own book on his own language uses .c as the extension, so how could it be the "only standardized extension"? --bb
Feb 27 2008
parent reply Walter Bright <newshound1 digitalmars.com> writes:
Bill Baxter wrote:
 Weird.  I mean I don't even think Stroustrup's own book on his own 
 language uses .c as the extension, so how could it be the "only 
 standardized extension"?
You motivated me to look! On page 28 of Stroustrup's "The C++ Programming Language" Special Edition 2.4.1: "The user code goes in a third file, say user.c."
Feb 27 2008
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Walter Bright wrote:
 Bill Baxter wrote:
 Weird.  I mean I don't even think Stroustrup's own book on his own 
 language uses .c as the extension, so how could it be the "only 
 standardized extension"?
You motivated me to look! On page 28 of Stroustrup's "The C++ Programming Language" Special Edition 2.4.1: "The user code goes in a third file, say user.c."
Well I'll be darned. I looked for my copy around here before I posted but couldn't find it. --bb
Feb 27 2008
prev sibling parent Sean Kelly <sean invisibleduck.org> writes:
== Quote from Robert Fraser (fraserofthenight gmail.com)'s article
 When I took my first class that introduced C and C++ programming, the
 professor said that ".c" was the only standardized extension for C++
 files, and that ".cpp",".cc", and ".cxx" were nonstandard and shouldn't
 be used.
I believe ".cpp" historically represented C pre-processor files, in fact. Sean
Feb 28 2008
prev sibling next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
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.
 Calling it "commonly used" is a stretch.
C++, from day 1, never standardized on an extension. If it had, this discussion would be moot.
Feb 27 2008
next sibling parent Bill Baxter <dnewsgroup billbaxter.com> writes:
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
Feb 27 2008
prev sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Walter Bright:
 C++, from day 1, never standardized on an extension. If it had, this 
 discussion would be moot.
I think today ".c++" and "cpp" are rather a de facto standard... And all my editors and IDEs recognize them as C++ sources. Where I work the personal preferences are things like the colors to show on screen used by the syntax highlighting, but not the file extensions to use. Bye, bearophile
Feb 28 2008
parent reply "Anders Bergh" <anders1 gmail.com> writes:
On Thu, Feb 28, 2008 at 10:29 AM, bearophile <bearophileHUGS lycos.com> wrote:
  I think today ".c++" and "cpp" are rather a de facto standard...
I don't think I've ever seen ".c++" used. "cpp" and "cc" however seem quite common. Anders
Feb 28 2008
parent Robert Fraser <fraserofthenight gmail.com> writes:
Anders Bergh wrote:
 On Thu, Feb 28, 2008 at 10:29 AM, bearophile <bearophileHUGS lycos.com> wrote:
  I think today ".c++" and "cpp" are rather a de facto standard...
I don't think I've ever seen ".c++" used. "cpp" and "cc" however seem quite common. Anders
".c++" sounds like it might be painful for certain file systems.
Feb 28 2008
prev sibling parent reply =?UTF-8?B?SnVsaW8gQ8Opc2FyIENhcnJhc2NhbCBVcnF1aWpv?= writes:
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. -- Julio César Carrascal Urquijo http://jcesar.artelogico.com/
Feb 28 2008
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
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
Feb 28 2008
parent reply Leandro Lucarella <llucax gmail.com> writes:
Bill Baxter, el 29 de febrero a las 06:56 me escribiste:
 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.
This is a more accurate search: "lang:c++ file:\.c$" It throw 334,000 results. "lang:c++ file:\.cpp$": 2,190,000 "lang:c++ file:\.cxx$": 293,000 "lang:c++ file:\.cc$": 770,000 Not to mention that, as said earlier, build tools tend to interpret .c as C code (make for example, use a C compiler for .c and C++ compiler for .cpp, so is a PITA if you use .c as extension for C++ files has you have to define the rule for compile them). -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------------- "CIRILO" Y "SIRACUSA" DE "SEÑORITA MAESTRA": UNO MUERTO Y OTRO PRESO -- Crónica TV
Feb 29 2008
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Leandro Lucarella wrote:
 Bill Baxter, el 29 de febrero a las 06:56 me escribiste:
 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.
This is a more accurate search: "lang:c++ file:\.c$" It throw 334,000 results.
Most of those appear to be capital-C not lower-case c. That's a reasonable choice for people who care only about Unix-y file systems. --bb
Feb 29 2008