What is the difference between the following to statements:
1. #include <abc.h>
2. #include "abc.h"
Regards
Printable View
What is the difference between the following to statements:
1. #include <abc.h>
2. #include "abc.h"
Regards
Hi!
According to MSDN The #include Directive :Quote:
....
#include "path-spec"
#include <path-spec>
The path-spec is a filename optionally preceded by a directory specification. The filename must name an existing file. The syntax of the path-spec depends on the operating system on which the program is compiled.
Both syntax forms cause replacement of that directive by the entire contents of the specified include file. The difference between the two forms is the order in which the preprocessor searches for header files when the path is incompletely specified.
Syntax Form Action
Quoted form This form instructs the preprocessor to look for include files in the same directory of the file that contains the #include statement, and then in the directories of whatever files that include (#include) that file. The preprocessor then searches along the path specified by the /I compiler option, then along paths specified by the INCLUDE environment variable.
Angle-bracket form This form instructs the preprocessor to search for include files first along the path specified by the /I compiler option, then along the path specified by the INCLUDE environment variable.
The preprocessor stops searching as soon as it finds a file with the given name. If you specify a complete, unambiguous path specification for the include file between two sets of double quotation marks (" "), the preprocessor searches only that path specification and ignores the standard directories.
....
According to the ISO standard (section 16.2),
In other words, the quoted form should always find a header that the <> form would, but not the other way around.Quote:
2 A preprocessing directive of the form
# include <hcharsequence> newline
searches a sequence of implementation defined places for a header identified uniquely by the specified sequence between the < and > delimiters, and causes the replacement of that directive by the entire contents of the header. How the places are specified or the header identified is implementation-defined.
3 A preprocessing directive of the form
# include "qcharsequence" newline
causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the " delimiters. The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read
# include <hcharsequence> newline
with the identical contained sequence (including > characters, if any) from the original directive.
In practice, use the <> form for system headers and the quoted form for application-specific headers.
Thanks all,Quote:
In other words, the quoted form should always find a header that the <> form would, but not the other way around.
In practice, use the <> form for system headers and the quoted form for application-specific headers.
I am using a library in my project. When I build it in debug mode it builds fine. But when in Releease mode the header files are not found!!! If i give absolute path it works.
The "include directories" for both the configurations is the same.
The problem is solved by replacing #include "lib.h" by #include <lib.h>?
The library is a third-party thing I only have the headers.
Regards
Because the search is implementation defined, you will need to consult the compiler's documentation to see how it implements each format.
If it works in debug but not release, you have different settings for each so when you change one, it is not reflected in the other unles you did so specifically, update the release settings.
Make sure your include path is the same for both debug and release. As a good rule of thumb, use the <> format when the header file is not contained within you project's directory structure, and use the "" format when it is.
Thanks
As I said "include directories" for both the configs is the sameQuote:
Make sure your include path is the same for both debug and release. As a good rule of thumb, use the <> format when the header file is not contained within you project's directory structure, and use the "" format when it is.
Any other parameter that I should check.
Though the search method or sequence is different both must always search include directories right ?
Regards
Often, the include directory is set per build type. Maybe you just haven't set your include directory properly for relase build?