Archived

This topic is now archived and is closed to further replies.

SirGorthon

Header files

Recommended Posts

Guest Anonymous Poster
The difference between the <> and the "" is which directory the compiler searches when looking for the file. If <> are used as the delimiters, then it looks in the directory where the inbuilt library header files are stored. If you use "" then the compiler looks in the directory of the .cpp file (or project)\

Rule of thumb -- If its your file use quotes. Otherwise use the angle brackets.

-D

Share this post


Link to post
Share on other sites
<> 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.)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Whether to use the .h or not is a bit more complex. If it the file is part of the old c standard then you want to prefix the name with a ''c'' and drop the .h -- <cmath> <cstring> <cstdlib> for instance. If it is a new STL header file, then just drop the .h -- <iostream> <iomanip> <vector> are a few. If it is a compiler-specific file, then you usually keep the .h <conio.h> is an example that is borland specific. Finally, if it is your own file, then just put the filename (which should usually contain a .h) -- "MyHeader.h" "SuperSpecialClass.h" etc.

-D

Share this post


Link to post
Share on other sites