When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
Pablo 12 2528
Pablo Suarez writes:
When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
Each compiler has its on preconfigured list of directories which it searches
for the header files. This is a compiler-specific setting. Check the
documentation for your compiler if you need to know what they are.
Most compilers recognize the -I option that adds a directory to the list of
directories it searches for header files. Incidentally, if the compiler does
not find "filename.h" in the current directory (actually, not the current
directory, but the directory where the source file, that referenced this
header file, is located), it continues to search for filename.h in the same
list of directories. The only actual difference between "filename.h" and
<filename.his that the former one is searched for in the source directory
first.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQBIL5AUx9p3GYHlUOIRAm8oAJ0R1AmBVivAlOTO1pHWIp 77jKgmIgCeO2H0
eugRkuTsFq3oKysXEgfosi4=
=gKNy
-----END PGP SIGNATURE-----
Pablo Suarez wrote:
When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
Depends on the compiler. However the compiler is set up to search for them.
Standard library header directories, etc...
Are you asking what the standard says about this, how to determine for your
specific compiler or something else?
--
Jim Langston ta*******@rocketmail.com
Pablo Suarez wrote:
When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
There are two answers to this, one as given by the C and C++ language
standards and one that applies in reality.
1. The language defines several so-called headers like <stdio.h(C) or
<iostream(C++). These are not ever required to be files at all, it is
only required to have certain effects if you include them. In reality, most
compilers install these headers as part of the compiler installation.
2. In practice, you will find in the same dir as other compiler-supplied
headers are installed in also some files that are system-dependent.
Further, often libraries install their header files in that dir or add a
directory with their headers to the path searched for system include files.
Suggestion: if file X includes file Y, use #include "Y" if Y is part of the
same program or library as X. If Y belongs to a separate library, use
#include <Yand if necessary adjust the compiler settings to include that
library.
Uli
Pablo Suarez wrote:
When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
Pablo
Hi,
When you write :
#include <myheader.h>
myheader.h is searched in the default system include directories. Under
Unix, it's typically /usr/include, /usr/X11/include, ...
Pablo Suarez wrote:
When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
Pablo
hi, each compiler will put the standard header files in some directory
,eg, I'm using Visual c++, the directory is something like Microsoft
Visual Studio\VC98\INCLUDE...
so, depend on the compiler you use, you can find them. Also, with -I,
you can specifies an additional directory to search for include files.
On May 19, 2:38 am, Shen-Ou YE <shenou...@gmail.comwrote:
Pablo Suarez wrote:
When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
When you write :
#include <myheader.h>
myheader.h is searched in the default system include
directories. Under Unix, it's typically /usr/include,
/usr/X11/include, ...
Not only. First, any directories specified by -I are searched,
then some compiler specific directories
("/opt/SUNWspro/include", for example, or
"~/gnu/gcc/install-4.1.0/include"), and finally the default
system directories (usually just "/usr/include"). Of course,
the first form of the include will search all these as well, if
it doesn't find the file in the directory where the source file
including it is located.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On May 17, 7:01*pm, pcs...@yahoo.com (Pablo Suarez) wrote:
When I code
#include "myheader.h"
then this header file is searched in the current directory.
Almost. It is *first* looked for in the current directory.
If not found, it *may* be looked for in other places,
according to implementation-dependent rules.
>
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
It is looked for in implementation-defined "standard" directories.
ON *nix, this is usually /usr/include.
Also, most compilers allow command-line options to specify
additional directories to be searched BEFORE the standard place(s),
using the -I option:
cc -I/MyDirectory -I/MyOtherDirectory ...
These directories will be searched for with either of the #include
styles.
--
Fred Kleinschmidt
"Pablo Suarez" <pc****@yahoo.comwrote in message
When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
You specify it to the compiler. Check your compiler's documentation as to
how you control it so search directories for header files. With gcc the
option is -I.
-- http://techytalk.googlepages.com
Pablo Suarez schrieb:
When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
Pablo
INCLUDE Environment variable or compiler searchpath (-I ..)
On May 19, 8:36 pm, Fred <fred.l.kleinschm...@boeing.comwrote:
On May 17, 7:01 pm, pcs...@yahoo.com (Pablo Suarez) wrote:
When I code
#include "myheader.h"
then this header file is searched in the current directory.
Almost. It is *first* looked for in the current directory.
If not found, it *may* be looked for in other places,
according to implementation-dependent rules.
It's very much compiler dependent, but I don't know of any which
look in the current directory (unless you specifically tell the
compiler to do so).
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
It is looked for in implementation-defined "standard" directories.
ON *nix, this is usually /usr/include.
Again, it's very implementation dependent, and almost always
includes more than just /usr/include.
Also, most compilers allow command-line options to specify
additional directories to be searched BEFORE the standard place(s),
using the -I option:
cc -I/MyDirectory -I/MyOtherDirectory ...
These directories will be searched for with either of the
#include styles.
The rules say that for an "..." include, if the search fails,
the compiler must then treat it as a <...include.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
On Mon, 19 May 2008 15:18:14 -0700, sk_usenet wrote:
"Pablo Suarez" <pc****@yahoo.comwrote in message
>When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
You specify it to the compiler. Check your compiler's documentation as
to how you control it so search directories for header files. With gcc
the option is -I.
Further to this: if you want to know where the current invocation of g++
is searching for headers (system and other), specify the -v option on the
g++ command.
--
Lionel B
On May 17, 9:01*pm, pcs...@yahoo.com (Pablo Suarez) wrote:
When I code
#include "myheader.h"
then this header file is searched in the current directory.
But where does the compiler search the header file when I write
#include <myheader.h>
instead?
Pablo
Pablo,
I belive, if I'm not mistaken, it searches the current directory. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: steve |
last post by:
I am quite frustrated with php’s include, as I have spent a ton of
time on it already... anyone can tell me why it was designed like this
(or something I don’t get)?
The path in include is...
|
by: Michael |
last post by:
There seem to be two ways to include files on the server:
1. <!-- #include file="header.inc" -->
2. <script language="VBScript" runat="server" src="header.inc"></script>
What are the differences...
|
by: mescaline |
last post by:
Hi,
Suppose a_file.cpp contains a function a_function()
Now to include it in main_file.cpp I just do #include "a_file.cpp" and
I'm all set.
i recently came across this seemingly roundabout...
|
by: Exits Funnel |
last post by:
Hello,
I'm a little confused about where I should include header files and was
wondering whether there was some convention. Imagine I've written a
class foo and put the definition in foo.h and...
|
by: Tuckers |
last post by:
My question is, if I have created my own library which lives in its own
install directory, to refer to its header file is it better to use
#include "MyLibrary.h"
or
#include <MyLibrary.h>
...
| |
by: Matt Jensen |
last post by:
Howdy
I want to simulate with .Net what I used to do with classic ASP where you
would have a series of include files with utility functions that you would
include when you needed them.
I read...
|
by: Andrew |
last post by:
Hello, friends,
In ASP, we use <!-- include --> to include header/footer files. What are
recommended to do in ASP.net? Any sample source code or reference papers?
Thanks a lot for your help.
|
by: John Smith |
last post by:
I have a project that consists of about a dozen translation
units. I use a command line compiler and it occured to me that I
could simplify compiling the project by #include(ing) them in a
header...
|
by: Colin Caughie |
last post by:
Is there a general rule/convention for when to use angle brackets and
when to use quotes in #include statements? Is the angle bracket reserved
for "system" header files (e.g. standard library...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |