?

Log in

No account? Create an account

C++ File Naming Conventions Poll

« previous entry | next entry »
Oct. 31st, 2007 | 08:57 pm

Dear LazyWeb,

Please provide insight :)

I am wondering what the common beliefs are regarding C++ file extensions. To come up with an answer I have decided to take a poll (which will not only be unscientific, but probably biased to those who care enough to hit a submit button).

What file extension should be used for C++ include files?

.h (you suck, this should be c)
10(55.6%)
.hpp
3(16.7%)
.hh
3(16.7%)
.h++
0(0.0%)
.hxx
2(11.1%)

What file extension should be used for C++ source files?

.cc
9(47.4%)
.cpp
10(52.6%)
.c++
0(0.0%)

More polls on squirrels?

Doom!
9(64.3%)
Cowboyneal!
5(35.7%)


If you can not see the poll then you are not viewing this post on Livejournal (so go see the original post).

This has nothing to do with MySQL... though I am sure more then a few of our developers have an opinion on this :)

Link | Leave a comment | Share

Comments {11}

Dreamer of the Day

(no subject)

from: iamo
date: Nov. 1st, 2007 05:12 am (UTC)
Link

Anything but .H and .C, really. That's just evil.

Reply | Thread

Dreamer of the Day

(no subject)

from: iamo
date: Nov. 1st, 2007 05:15 am (UTC)
Link

You're also missing an option (aside from the too evil to consider one I mentioned above). No extension at all on headers, ala the C++ standard lib. The real problem in C++ tends to be when templates are involved and the common boundary between code and header start to fall apart. The more into the C++ way of doing things you get, the more often that happens, and these kinds of questions become much more academic than they are in C.

Reply | Parent | Thread

Lover of Ideas

Template metaprogramming means that headers are no longer headers

from: omnifarious
date: Nov. 1st, 2007 08:48 am (UTC)
Link

This is true. My usual solution for template code that's really too big for a header is to make a separate .cpp file in the header directory and to #include it in the header. That strategy is followed by a few other things I've seen as well.

Reply | Parent | Thread

Lover of Ideas

(no subject)

from: omnifarious
date: Nov. 1st, 2007 08:25 am (UTC)
Link

My favorite with C++ for awhile was .cxx, but the stupid Windows based versions of C++ all want cpp and nothing else. *sigh*


Personally, even though + is a shell metacharacter I think .c++ and .h++ should be used on all the systems. It would possibly teach Unix people to stop writing shell scripts that broke when filenames had shell metacharacters in them.

Reply | Thread

Brian "Krow" Aker

(no subject)

from: krow
date: Nov. 1st, 2007 08:41 am (UTC)
Link

Does Visual Studio support .hpp?

Reply | Parent | Thread

Lover of Ideas

(no subject)

from: omnifarious
date: Nov. 1st, 2007 08:45 am (UTC)
Link

Yes, I believe Visual Studio does support .hpp. Boost using it is a really good indicator. That library tries very hard to be as cross-platform as it possibly can. It's also a really good library in general.

Reply | Parent | Thread

David

(no subject)

from: dblume
date: Nov. 1st, 2007 03:12 pm (UTC)
Link

Confirmed. Visual Studio shouldn't have a problem with any of the extensions you named, except for h++ and c++.

Reply | Parent | Thread

Dreamer of the Day

(no subject)

from: iamo
date: Nov. 1st, 2007 04:47 pm (UTC)
Link

Why would visual studio have a problem with .h++? Unless you mean the IDE having trouble with knowing to syntax highlight it. That doesn't imply that it can't deal with it in the compile process. It, like any other C++ compiler out there, really doesn't care.

Reply | Parent | Thread

David

(no subject)

from: dblume
date: Nov. 1st, 2007 04:59 pm (UTC)
Link

Sorry, I didn't mean that Visual Studio has a problem with .h++ and .c++. I meant that the status of those two extensions is not confirmed. (I didn't bother checking them.) I wasn't clear.

Reply | Parent | Thread

J. John Johnstown

(no subject)

from: gymgeek
date: Nov. 1st, 2007 06:21 pm (UTC)
Link

I have to admit, I haven't written much C++ code in the last 10 years. We get along just nicely with C in our embedded system. We have an aversion to dynamic memory allocation after init. (That's not to say we don't do it, we just don't like it.)

Reply | Thread

Menolly

(no subject)

from: nolly
date: Nov. 1st, 2007 06:57 pm (UTC)
Link

Hmm.. my C and C++ days are pretty far behind me now; I think the header files were .h for both in the environments I worked in. It's probably not ideal, but none of the other options feel right, either.

I've used both .cc and .cpp for source files, and don't have a preference,

Reply | Thread