Is using .h as a header for a c++ file wrong?
I see it all over the place, especially with code written in the ‘C style’. I noticed that Emacs always selects C highlighting style for a .h header, but c++ for hpp or hh.
Is it actually ‘wrong’ to label your headers .h or is it just something which annoys me?
EDIT:
There is a good (ish) reason why this annoys me, if I have project files labelled, ‘hpp & cpp’ I can get away with ‘grep something *pp’ etc. otherwise I have to type ‘.h cpp’
It’s not wrong to call your C++ headers .h. There are no rules of what extensions your code must use. For your non-headers, MSVC uses .cpp and on Linux, .cc as well. There is no one global standard, and .h is definitely very widely used.
But I’d say calling your headers .hpp (I’ve seen .hh a few times as well) is a lot more consistent and informative than just using .h.