Skip to main content
GameDev.net gamedev.net
🔒 Locked

Header files

Started by SirGorthon Aug 12, 2002 at 11:47 PM 4 replies 450+ views
Original Post
SirGorthon
SirGorthon
In an #include statement, when is it appropriate to use "" <> and .h? Or does it matter?
Miserable
Miserable
<> are used for "built-in" header files, i.e. those provided with the compiler. "" are used for your own, custom headers (which means that the compiler will use the project directory to look for them). As for the .h, you''re probably confused by the difference between, for instance, and and similar things. As I understand it, the .h files are depracated, and you are encouraged to use the newer headers (i.e. , not ). Be aware, however, that the new headers all take advantage of namespaces. (Also be aware that I''m new to some of this as well, but this is all as well as I understand it.)
Kevlar-X
Kevlar-X
Hey hey.

When using the #include directive in C using plain quotes indicates to the compiler to look in the current directory for the file.

When you use <> it looks in all the compiler defined directories, in the order they are defined.

so the statement:
#include "..\someheader.h" is valid, but
#include <..\someheader.h> just plain doesnt make sense

As for using ".h" at the end of things: If the file you wish to include is named with a ".h" at the end, you should use that in the include statement.

For STL stuff though, the prefered style (I believe) is just to omit the ".h". EG: use #include <assert> to get at the STL file "assert.h"

Hope that helps,


"1 is equal to 2 for significantly large quantities of 1" - Anonymous
"1 is equal to 2 for significantly large quantities of 1" - Anonymous
SirGorthon
SirGorthon
Thanks for all the help!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.