Header file-Urgent please 
Author Message
 Header file-Urgent please

I've to include one header file in a different directory. I've mentioned it
in the body of my program as #include"xxx.h" and #include <xxx.h>. In both
ways, it is not recognizing. Reporting an error that no such file. But xxx.h
is there on my system.
ANy suggestions please


Mon, 11 Nov 2002 03:00:00 GMT  
 Header file-Urgent please
Keith,

Quote:

> I've to include one header file in a different directory.
> I've mentioned it in the body of my program as #include"xxx.h"
> and #include <xxx.h>. In both ways, it is not recognizing.
> Reporting an error that no such file. But xxx.h is there on my
> system.

  Embrace the whole (absolute|relative) path of your header in double
quotes or use angle brakets with the file name only and tell the
compiler to add the place where this file is in to its list of "include
paths" (in a UNIX-like compiler the command line option could be
'-Ipathname').

        Best regards,
                Marco



Mon, 11 Nov 2002 03:00:00 GMT  
 Header file-Urgent please

Quote:

>I've to include one header file in a different directory. I've mentioned it
>in the body of my program as #include"xxx.h" and #include <xxx.h>. In both
>ways, it is not recognizing. Reporting an error that no such file. But xxx.h
>is there on my system.

by default, your program will only look in a few directories for header
files.  if you have a header file that isn't in one of those
directories, you have to tell your program where it lives.

you can do this by including the directory in your source code:

  #include "../xxx.h"
  #include "../directory/xxx.h"
  #include "/some/directory/path/xxx.h"

  (note: these are UNIX directory paths.  DOS directory paths will
  probably look different.)

or you can tell your compiler where to look to find the include file.
i can't tell you how to do this, because each compiler is different.

---
"... What with you being his parents and all, I think that you could
be trusted not to shaft him."  -- Robert Chang, rec.games.board




Mon, 11 Nov 2002 03:00:00 GMT  
 Header file-Urgent please

: I've to include one header file in a different directory. I've mentioned it
: in the body of my program as #include"xxx.h" and #include <xxx.h>. In both
: ways, it is not recognizing. Reporting an error that no such file. But xxx.h
: is there on my system.
: ANy suggestions please

It's not enough that xxx.h is somewhere on your system. It has to be in
a specific place. If you #include <xxx.h>, xxx.h must be in the system
include directory, where stdio.h, stdlib.h and all the other happy
little critters live. If you #include "xxx.h", however, xxx.h must be in
the same directory as your source code. If it's in a different
directory, you must tell it explicitly to the computer.
Example of this (assuming you are using Unix):

foo.c
headers/

xxx.h

#include "headers/xxx.h"
int main(void) {return 0;}

--

| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #80 D+ ADA N+++ |
| http://www.helsinki.fi/~palaste       W++ B OP+                     |
\----------------------------------------- Finland rules! ------------/

"Stronger, no. More seductive, cunning, crunchier the Dark Side is."
   - Mika P. Nieminen



Mon, 11 Nov 2002 03:00:00 GMT  
 Header file-Urgent please
Thanks to all of you whoever contributed answers....now I sorted out the
problem and found new problems. I've included by specifing the whole
directory path...say #include "path1\path2\xxx.h" and the path1 directory is
in the same directory as my source code is there. Now it is not complining
anything. But there are some more header files specified in the xxx.h. Those
header files are not in the same directory as xxx.h is. Now my compiler is
failed to locate those connecting header files to xxx.h.

How to sort this problem. Should have to modify the xxx.h header file by
specifying its connecting header file paths. But I wonder how somebody has
compiled successfully before me without bothering all these by simply
mentioning the #include "xxx.h".


Quote:

> >I've to include one header file in a different directory. I've mentioned
it
> >in the body of my program as #include"xxx.h" and #include <xxx.h>. In
both
> >ways, it is not recognizing. Reporting an error that no such file. But
xxx.h
> >is there on my system.

> by default, your program will only look in a few directories for header
> files.  if you have a header file that isn't in one of those
> directories, you have to tell your program where it lives.

> you can do this by including the directory in your source code:

>   #include "../xxx.h"
>   #include "../directory/xxx.h"
>   #include "/some/directory/path/xxx.h"

>   (note: these are UNIX directory paths.  DOS directory paths will
>   probably look different.)

> or you can tell your compiler where to look to find the include file.
> i can't tell you how to do this, because each compiler is different.

> ---
> "... What with you being his parents and all, I think that you could
> be trusted not to shaft him."  -- Robert Chang, rec.games.board





Mon, 11 Nov 2002 03:00:00 GMT  
 Header file-Urgent please


Quote:
> How to sort this problem. Should have to modify the xxx.h header file by
> specifying its connecting header file paths. But I wonder how somebody has
> compiled successfully before me without bothering all these by simply
> mentioning the #include "xxx.h".

Yes they probably have. Usually one of the compiler switches or an
environmental variable can say, "here is a list of directories to search for
for include files" and you make sure that it is specified.

As this point you need to consult your compiler documentation to find out
just _where_ it searches for include files when you do

#include "xxx.h"

This newsgroup cannot help you for _specifics_ for a compiler.

Stephen Howe



Mon, 11 Nov 2002 03:00:00 GMT  
 Header file-Urgent please

Quote:

>: I've to include one header file in a different directory. I've mentioned it
>: in the body of my program as #include"xxx.h" and #include <xxx.h>. In both
>: ways, it is not recognizing. Reporting an error that no such file. But xxx.h
>: is there on my system.
>: ANy suggestions please

>It's not enough that xxx.h is somewhere on your system. It has to be in
>a specific place. If you #include <xxx.h>, xxx.h must be in the system
>include directory, where stdio.h, stdlib.h and all the other happy
>little critters live. If you #include "xxx.h", however, xxx.h must be in
>the same directory as your source code.

More correctly, since the C standard has no reference to "directories",
the directive
#include <xxx.h>
"searches a sequence of implementation-defined places" for the header xxx.h,
and
#include "xxx.h"
causes the file xxx.h to be "searched for in an implementation-defined
manner".  The Unix C processors I'm familiar with look in the directories in
ways similar to what Joona describes (with variations on the algorithm if an
include file contains an #include directive), but other implentations are
free to use their own search methods.  For the original poster, I suggest
that you read the documentation for your compiler, to find out how it
searches for #included files, and if you can't find the answer in your
documentation, try asking in a newsgroup specific to your compiler or
operating system.
--

Kenan Systems Corp., a wholly-owned subsidiary of Lucent Technologies


Mon, 11 Nov 2002 03:00:00 GMT  
 Header file-Urgent please
Quote:

> Thanks to all of you whoever contributed answers....now I sorted out the
> problem and found new problems. I've included by specifing the whole
> directory path...say #include "path1\path2\xxx.h" and the path1 directory is
> in the same directory as my source code is there. Now it is not complining
> anything. But there are some more header files specified in the xxx.h. Those
> header files are not in the same directory as xxx.h is. Now my compiler is
> failed to locate those connecting header files to xxx.h.

[...]

Right, and before you know it, you have to hard-code the path to every
single header you use.  If you were so misled to even include a drive
name, as in:

  #include "c:\path1\path2\file.h"

then this program won't even compile when you copy the source to drive
D, and of course limits your freedom in moving headers from directory to
directory.  What you really want to do is to remove all that nonsense,
and leave only the name of the header, as in:

  #include <stdio.h>
  #include "file.h"

and then find out in your compiler documentation how to inform your
compiler on where to look for headers.  It might be in the form of an
environment variable, a command line option, or perhaps a configuration
file.  You should ask on a newsgroup dedicated to your platform if you
are really unable to find this in your compiler documentation.



Mon, 11 Nov 2002 03:00:00 GMT  
 Header file-Urgent please

Quote:

> Thanks to all of you whoever contributed answers....now I sorted out the
> problem and found new problems. I've included by specifing the whole
> directory path...say #include "path1\path2\xxx.h" and the path1 directory is

Apart from the other problems with this, I wasn't aware of the \p and \x
escape characters. You want either "path1\\path2\\xxx.h" or, preferably
(and this ought to work in every _real_ compiler) "path1/path2/xxx.h".

Richard



Tue, 12 Nov 2002 03:00:00 GMT  
 Header file-Urgent please
Richard,

Quote:

> preferably (and this ought to work in every _real_
> compiler) "path1/path2/xxx.h".

  And C will become PERL... :)

        Best regards,
                Marco



Tue, 12 Nov 2002 03:00:00 GMT  
 Header file-Urgent please

 >
 > > Thanks to all of you whoever contributed answers....now I sorted out the
 > > problem and found new problems. I've included by specifing the whole
 > > directory path...say #include "path1\path2\xxx.h" and the path1 directory is
 >
 > Apart from the other problems with this, I wasn't aware of the \p and \x
 > escape characters. You want either "path1\\path2\\xxx.h" or, preferably
 > (and this ought to work in every _real_ compiler) "path1/path2/xxx.h".

Not in an include directive.  Replacement of escape sequences takes place
after the processing of preprocessor directives.
--
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn  amsterdam, nederland; http://www.cwi.nl/~dik/



Tue, 12 Nov 2002 03:00:00 GMT  
 Header file-Urgent please
Quote:

>> Thanks to all of you whoever contributed answers....now I sorted out the
>> problem and found new problems. I've included by specifing the whole
>> directory path...say #include "path1\path2\xxx.h" and the path1 directory is


Quote:

>Apart from the other problems with this, I wasn't aware of the \p and \x
>escape characters.

(There is no \p; \x indicates hexadecimal in a C string, so "abc\xa!" is
the same as "abc\12!", which on ASCII systems, is the same as "abc\n!".)
But ...

Quote:
>You want either "path1\\path2\\xxx.h" or, preferably
>(and this ought to work in every _real_ compiler) "path1/path2/xxx.h".

... the thing inside double quotes after "#include" is not a C string,
but rather a "q-char-sequence", and its interpretation is up to your
C compiler.  It might require double backslashes; it might prohibit
double backslashes; it might accept both; or it might even require
that, to get to the file named "HOST::$DSK:[FOO.BAR]BAZ.H;37" (as
seen outside the C compiler), you must write:

        #include "snorkelfarb is a wonderful wonderful thing!"

Compilers are allowed to be arbitrarily evil about this.
--
In-Real-Life: Chris Torek, Berkeley Software Design Inc




Tue, 12 Nov 2002 03:00:00 GMT  
 Header file-Urgent please


Quote:

>> Thanks to all of you whoever contributed answers....now I sorted out the
>> problem and found new problems. I've included by specifing the whole
>> directory path...say #include "path1\path2\xxx.h" and the path1 directory is

>Apart from the other problems with this, I wasn't aware of the \p and \x
>escape characters. You want either "path1\\path2\\xxx.h" or, preferably
>(and this ought to work in every _real_ compiler) "path1/path2/xxx.h".

Whoops!  You forgot that #includes are read by the preprocessor, not
the compiler, so \\ is not needed...

and fortunately every *real* compiler does like /. Including all the
Microsoft ones... :-?

--
Mark McIntyre
C- FAQ: http://www.eskimo.com/~scs/C-faq/top.html



Tue, 12 Nov 2002 03:00:00 GMT  
 Header file-Urgent please


Quote:
> Thanks to all of you whoever contributed answers....now I sorted out the
> problem and found new problems. I've included by specifing the whole
> directory path...say #include "path1\path2\xxx.h"

Don't do this.

Embedding explicit paths in your program is a guaranteed way to make it
hard to port to different systems, and hard for you to rearrange the
directories where your code lives. (For example, I have a medium-sized
program which lives in one source directory. I intend to carve it up
along sensible boundaries and distribute the source among welll-named
directories; and I {*filter*}y well am *not* going to keep tinkering with
the #include's in the source files.)

Almost any decent compiler will have a way to be told "look for include
files in *here* and in *here* and in ...". Use that.

Under Unixy systems, its a -Idirectory command-line option to the C
compiler. If you're cursed with an IDE, it's probably some arcane option
buried at the end of an obscure menu tree.

--
Chris "cynical? moi?" Dollin
C FAQs at: http://www.*-*-*.com/



Tue, 12 Nov 2002 03:00:00 GMT  
 Header file-Urgent please
[Chris Torek]

Quote:
>   ... the thing inside double quotes after "#include" is not a C string,
>   but rather a "q-char-sequence", and its interpretation is up to your
>   C compiler.  It might require double backslashes; it might prohibit
>   double backslashes; it might accept both; or it might even require
>   that, to get to the file named "HOST::$DSK:[FOO.BAR]BAZ.H;37" (as
>   seen outside the C compiler), you must write:

>    #include "snorkelfarb is a wonderful wonderful thing!"

>   Compilers are allowed to be arbitrarily evil about this.

Or helpful.  On RISC OS (the Acorn OS) the directory separator is ".",
so you keep all your header files in the subdirectory "h", all the
source code in the subdirectory "c", and the object files go in the
subdirectory "o", which makes for a very tidy layout, albeit unusual.

If you write #include <sys/types.h>, the compiler will go looking for
the file "xxx.sys.h.types", so it is easy to write portable code in
this respect.

Kjetil T.



Sun, 17 Nov 2002 03:00:00 GMT  
 
 [ 15 post ] 

 Relevant Pages 

1. Using one header file for several source files - help please

2. C Header files including header files, mutually referencing typedefs

3. STL header files vs non-STL header files

4. Please help. Need header files

5. Please Help, I need some Network Header Files.

6. .LIBs and Header files (PLEASE HELP!)

7. URGENT URGENT PLEASE HELP ME ActiveX multiples classes

8. Help with Header file, please?

9. Missing files!!!please I need urgent help...

10. Urgent.......Please See Regarding the registration of file types

11. Very Urgent !!! please please help

12. Please please: urgent&important

 

 
Powered by phpBB® Forum Software