why never .hpp

F699ebb187331fdf7f7875320e3e7e3e
0
starboarder2001 101 Oct 28, 2003 at 23:25

Why arent any of the C++ headers .hpp? All the source I have looked at use .cpp but not .hpp? :huh:

12 Replies

Please log in or register to post a reply.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Oct 28, 2003 at 23:53

lol, good question :)
boost uses .hpp. can’t give you any real answer though why nobody uses it… to be honest i never thought about using .hpps

22b3033832c5c699c856814b0cf80cb1
0
bladder 101 Oct 29, 2003 at 00:50

@starboarder2001

Why arent any of the C++ headers .hpp? All the source I have looked at use .cpp but not .hpp? :huh:

I guess it’s becuase most people that program in C++ (or most people that teach C++) used to be C people. With C there was .c and .h so that’s why the .h is still common. The .c went out becuase you *have* to name your file .cpp (or something else, .cc, .cxx) for the compiler to know that its C++ code and not C code. But you dont *have* to name your file with a .hpp etention for the compiler to know that its a C++ header file, becuase teh compiler just dosnt give a damn about header files.

I think that’s a good enough answer :)

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Oct 29, 2003 at 00:52

reasonable answer…
phear the preprocessor !!!

2562953b4e8e2602a8bfc24b1123a341
0
EvilSmile 101 Oct 29, 2003 at 04:19

@bladder

@starboarder2001

Why arent any of the C++ headers .hpp? All the source I have looked at use .cpp but not .hpp? :huh:

I guess it’s becuase most people that program in C++ (or most people that teach C++) used to be C people. With C there was .c and .h so that’s why the .h is still common. The .c went out becuase you *have* to name your file .cpp (or something else, .cc, .cxx) for the compiler to know that its C++ code and not C code. But you dont *have* to name your file with a .hpp etention for the compiler to know that its a C++ header file, becuase teh compiler just dosnt give a damn about header files.

I think that’s a good enough answer :)

It may also have something to do with the fact that cpp can use c style functions (extern “C”…)

1c524bd2186804f828ea3e1a3216a294
0
alia 101 Oct 29, 2003 at 05:04

I find it usefull to only use .hpp if the file is C++ specific.. ie templates/classes etc and .h if the file contains common code.

A.

22b3033832c5c699c856814b0cf80cb1
0
bladder 101 Oct 29, 2003 at 14:21

@alia

I find it usefull to only use .hpp if the file is C++ specific.. ie templates/classes etc and .h if the file contains common code.

A.

I prefer extentionsless header files. Like how the STL uses them. That way everything can be arranged according to namespace and/or class names ie:

#include <particlesystem/manager>

ParticleSystem::Manager mgr;

Though I havent figured out how to make msvc acknowledge the extentionless header files and color code it and all.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Oct 29, 2003 at 14:47

Though I havent figured out how to make msvc acknowledge the extentionless header files and color code it and all.

as msvc recognizes files by extension this won’t be possible…

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Oct 29, 2003 at 16:32

as said above, I think it’s just force of habit. Many people were used to .c and .h. When they moved to C++, they had to change the .c, but not the .h so they left the .h.

Too many ‘.’s.

22b3033832c5c699c856814b0cf80cb1
0
bladder 101 Oct 30, 2003 at 12:38

@anubis

Though I havent figured out how to make msvc acknowledge the extentionless header files and color code it and all.

as msvc recognizes files by extension this won’t be possible…

yeah but if you #include <vector> or some other stl header, then right click and chose to open the file, you’ll see that everything is color coded in there. So it’s possible, just dont know how.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Oct 30, 2003 at 13:00

but then again… the stl comes with the compiler
on the other hand, maybe there is a way to set code coloring on a per folder basis

590e8bdac8129bd87b188df15e62d0e5
0
CyraX 101 Oct 31, 2003 at 14:03

.hpp files cannot generate percompiled headers

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Oct 31, 2003 at 21:13

@anubis

but then again… the stl comes with the compiler
on the other hand, maybe there is a way to set code coloring on a per folder basis

indeed, there is a file where all stl filenames are written into, and vs.net highlights them just as normally only .cpp and .h