Jump to content


why never .hpp


12 replies to this topic

#1 starboarder2001

    Member

  • Members
  • PipPip
  • 35 posts

Posted 28 October 2003 - 11:25 PM

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

#2 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 28 October 2003 - 11: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
If Prolog is the answer, what is the question ?

#3 bladder

    DevMaster Staff

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 29 October 2003 - 12:50 AM

starboarder2001 said:

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 :)

#4 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 29 October 2003 - 12:52 AM

reasonable answer...
phear the preprocessor !!!
If Prolog is the answer, what is the question ?

#5 EvilSmile

    Member

  • Members
  • PipPip
  • 96 posts

Posted 29 October 2003 - 04:19 AM

bladder said:

starboarder2001 said:

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"...)

#6 alia

    New Member

  • Members
  • PipPip
  • 28 posts

Posted 29 October 2003 - 05:04 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.
Never ever say never, except if you are saying this.

#7 bladder

    DevMaster Staff

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 29 October 2003 - 02:21 PM

alia said:

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.

#8 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 29 October 2003 - 02:47 PM

Quote

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...
If Prolog is the answer, what is the question ?

#9 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 29 October 2003 - 04:32 PM

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.
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.

#10 bladder

    DevMaster Staff

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 30 October 2003 - 12:38 PM

anubis said:

Quote

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.

#11 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 30 October 2003 - 01:00 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
If Prolog is the answer, what is the question ?

#12 CyraX

    Valued Member

  • Members
  • PipPipPip
  • 144 posts

Posted 31 October 2003 - 02:03 PM

.hpp files cannot generate percompiled headers

#13 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 31 October 2003 - 09:13 PM

anubis said:

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
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users