tags:

views:

202

answers:

2

hi,

for gcc they should be the same, right? which one of them is more popular , i am now preparing a project from scratch and i would like to pick one among these 2.

thanks

+13  A: 

In C++, the file extension doesn't actually matter. The use of .h, .hpp, .hxx, or no file extension are all by convention.

The standard library uses no file extension for its header files. Many projects, including Boost, use .hpp. Many projects use .h. Just pick one and be consistent in your project.

James McNellis
One problem I've run into with .h extensions for C++ headers is that some editors think they're C, and then you get lots of ugly syntax highlighting problems as soon as there's a 'namespace' or 'class' or something.
Fred Larson
For example, see my question: http://stackoverflow.com/questions/226402/make-eclipse-treat-h-file-as-c
Fred Larson
A: 

Header file extensions don't usually make a difference, but I know that in some cases the extension of the .cpp file can make a difference. Depending on your compiler the front-end may choose to compile the source file as either C or C++.

This can make a difference, especially if you are combining compilation with the link phase, as it can lead to different libraries being linked (e.g. g++ vs gcc) and so you can control the outcome in your makefile.

Robert Tuck