Hi can anyone explain to me What is the difference between #include<headerfile.h> and #include "headerfile.h"?
Thanks a lot..................
What is the difference between #include<headerfile.h> and #incluWhat is the difference between #include<headerfile.h> and #inclu
Page 1 of 1
7 Replies - 3185 Views - Last Post: 28 February 2008 - 11:40 AM
#1
What is the difference between #include<headerfile.h> and #inclu
Posted 27 February 2008 - 05:44 PM
Replies To: What is the difference between #include<headerfile.h> and #inclu
#2
Re: What is the difference between #include<headerfile.h> and #inclu
Posted 27 February 2008 - 06:27 PM
You use quotes when you're specifying the path of the header file.
You use the "<...>" when the header file is in a system directory like /usr/include (Unix, in Windows I think it's somewhere in one of the system folders).
You can usually specify an additional include directory (so you can use the "<...>") as a compiler flag (depending on which compiler you use).
For example, since stdio.h is in my system's include path, I can include it by doing #include <stdio.h>. However it would also work if I used quotes and specified the path like this #include "/usr/include/stdio.h".
You use the "<...>" when the header file is in a system directory like /usr/include (Unix, in Windows I think it's somewhere in one of the system folders).
You can usually specify an additional include directory (so you can use the "<...>") as a compiler flag (depending on which compiler you use).
For example, since stdio.h is in my system's include path, I can include it by doing #include <stdio.h>. However it would also work if I used quotes and specified the path like this #include "/usr/include/stdio.h".
#3
Re: What is the difference between #include<headerfile.h> and #inclu
Posted 27 February 2008 - 06:44 PM
The <...> are for system headers. (The default includes, like iostream, stdlib, etc.).
The "..." are for custom headers, i.e., ones you've written for your project.
The "..." are for custom headers, i.e., ones you've written for your project.
#4
Re: What is the difference between #include<headerfile.h> and #inclu
Posted 27 February 2008 - 06:54 PM
Thanks. it helps a lot.
#5
Re: What is the difference between #include<headerfile.h> and #inclu
Posted 27 February 2008 - 07:03 PM
A difference is that in the quoted form i.e. #include "something" the preprocessor will search the paths of all files in the project that include the same file.
With the angled bracket form, that is not done, it only searches the INCLUDE environment variable, and the path specified in the "/I" compiler option. The quoted form does this as well.
Have a codeful day
With the angled bracket form, that is not done, it only searches the INCLUDE environment variable, and the path specified in the "/I" compiler option. The quoted form does this as well.
This post has been edited by Nayana: 27 February 2008 - 07:11 PM
#6
Re: What is the difference between #include<headerfile.h> and #inclu
Posted 28 February 2008 - 04:44 AM
#include <file>
This variant is used for system header files. It searches for a file named file in a standard list of system directories.
#include "file"
This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>.
Check This link:
developer.apple.com/DOCUMENTATION/DeveloperTools/gcc-4.0.1/cpp/Header-Files.html#Header-Files
This variant is used for system header files. It searches for a file named file in a standard list of system directories.
#include "file"
This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>.
Check This link:
developer.apple.com/DOCUMENTATION/DeveloperTools/gcc-4.0.1/cpp/Header-Files.html#Header-Files
#7
Re: What is the difference between #include<headerfile.h> and #inclu
Posted 28 February 2008 - 11:34 AM
Four nearly identical answers?
If ever a thead needed closing, this is it.
If ever a thead needed closing, this is it.
#8
Re: What is the difference between #include<headerfile.h> and #inclu
Posted 28 February 2008 - 11:40 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|