View Full Version : why never .hpp
starboarder2001
10-28-2003, 04:25 PM
Why arent any of the C++ headers .hpp? All the source I have looked at use .cpp but not .hpp? :huh:
anubis
10-28-2003, 04:53 PM
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
bladder
10-28-2003, 05:50 PM
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 :)
anubis
10-28-2003, 05:52 PM
reasonable answer...
phear the preprocessor !!!
EvilSmile
10-28-2003, 09:19 PM
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"...)
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.
bladder
10-29-2003, 07:21 AM
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.
anubis
10-29-2003, 07:47 AM
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...
baldurk
10-29-2003, 09:32 AM
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.
bladder
10-30-2003, 05:38 AM
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.
anubis
10-30-2003, 06:00 AM
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
CyraX
10-31-2003, 07:03 AM
.hpp files cannot generate percompiled headers
davepermen
10-31-2003, 02:13 PM
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
vBulletin, Copyright ©2000-2009, Jelsoft Enterprises Ltd.