473,320 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Header Inclusion style

If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then 'myHeader.h' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

What setting do I need to do such that, the latter syntax also accepted
for my headers ?
Nov 13 '05 #1
14 2314
qazmlp wrote:
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then 'myHeader.h' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

What setting do I need to do such that, the latter syntax also accepted
for my headers ?


[replied only in c.l.c]

None that you should know about. The latter syntax is reserved for
standard headers (in the ISO C meaning of the term), and any header your
implementation is willing to consider standard.

Your own headers are your own only, and should always be included with
the #include "foo.h" syntax.

--
Bertrand Mollinier Toublet
"Reality exists" - Richard Heathfield, 1 July 2003

Nov 13 '05 #2
qa********@rediffmail.com (qazmlp) wrote:
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then 'myHeader.h' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

What setting do I need to do such that, the latter syntax also accepted
for my headers ?


The <...> notation finds headers "in the standard places", hence
system headers, as opposed to those that you provide, will be
found.

The "..." notation probably looks in the current working
directory first, and will thus include headers you provide,
before looking in the same places that <...> will look.

That means you probably want to use the different notations
thusly,

#include <stdio.h> /* header provided by the platform */
#include "myhdr.h> /* header provided by the program */

With unix style compilers you also have the option of adding to
the places the compiler thinks of as "standard", usually with
the -I option. Hence invoking the compiler with '-I./include'
will cause the <...> notation to also look in the ./include
directory for headers.

You'll definitely want to read the documentation for your
compiler. You can also look for an option that will tell you
more about what it is doing. For example, with the GNU C
compiler, gcc, you can give it the -v option and it will
verbosely explain what it is doing and where it is searching for
headers (and libraries, and whatever).

--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) fl***@barrow.com
Nov 13 '05 #3
On 7 Jul 2003, qazmlp wrote:
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then 'myHeader.h' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

What setting do I need to do such that, the latter syntax also accepted
for my headers ?


The places searched are implementation defined for both formats. You'd
have to consult your compiler documentation to find out where it searches
for the different headers.

Typically, #include <file.h> will search the system header files and
#include "file.h" will search the project header files and then the system
header files.

Why is it important that you use #include <file.h> to find your header
files? If I looked at your source code I would assume the header file is
an implementation specific header file for a certain compiler. It would
not immediately occur to me that it was a project header file. When I see
#include "file.h" I immediately think this is a file created by the
project programmer and not the compiler company. This is all jut
convention but having conventions makes it easier for you to work with
others.

--
main(){int j=1234;char t[]=":@abcdefghijklmnopqrstuvwxyz.\n",*i=
"iqgbgxmdbjlgdv.lksrqek.n";char *strchr(const char *,int);while(
*i){j+=strchr(t,*i++)-t;j%=sizeof t-1;putchar(t[j]);} return 0;}

Nov 13 '05 #4
JCB
qa********@rediffmail.com (qazmlp) wrote in message news:<db*************************@posting.google.c om>...
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then 'myHeader.h' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

What setting do I need to do such that, the latter syntax also accepted
for my headers ?

I don't think you can.
If it was the case, your program will be less clear, because less easy
to distinguish beetween standard headers and "personnal" headers.

Just one question : why do you want to use the <file.h> syntax with
your personal headers ???
Nov 13 '05 #5
Floyd Davidson <fl***@barrow.com> writes:
#include "myhdr.h> /* header provided by the program */


Is that a joke?
Nov 13 '05 #6


qazmlp wrote:

If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then 'myHeader.h' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

This guy just HAS to be trolling. He's supposedly been studying C and
C++ for over a year now, he's posted dozens if not hundreds of questions
to various groups, all of them these simplistic matters that he could
have figured out by reading the books he claims to own or from a brief
google search.


Brian Rodenborn
Nov 13 '05 #7
In 'comp.lang.c', qa********@rediffmail.com (qazmlp) wrote:
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then 'myHeader.h' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.
Good.
What setting do I need to do such that, the latter syntax also accepted
for my headers ?


The <> headers are reserved for the implementation (standard or not).
The "" headers are reserved for the user's headers.

--
-ed- em**********@noos.fr [remove YOURBRA before answering me]
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 13 '05 #8
In 'comp.lang.c', Dave Uhring <da********@yahoo.com> wrote:
On Mon, 07 Jul 2003 23:59:02 -0700, qazmlp wrote:
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then 'myHeader.h' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.
"myHeader.h" without that comma is in the current working directory.


This is completely implementation dependent.
<myHeader.h> is in /usr/include or one referenced by some -I/directory or
-isystem /somedirectory.


This is completely implementation dependent.

The good reason was exposed already on the other posts.

<> -> implementation
"" -> user

--
-ed- em**********@noos.fr [remove YOURBRA before answering me]
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 13 '05 #9
On Tue, 08 Jul 2003 19:28:11 +0000, Emmanuel Delahaye wrote:
This is completely implementation dependent.

The good reason was exposed already on the other posts.

<> -> implementation
"" -> user


Works the same way with gcc and Solaris cc. What is your point?

Nov 13 '05 #10
In 'comp.lang.c', Dave Uhring <da********@yahoo.com> wrote:
<> -> implementation
"" -> user


Works the same way with gcc and Solaris cc. What is your point?


It's a question of design. The <> headers are preprocessor directives. They
are not necessarely including a real file. They just tell the compiler to
behave 'as-it'.

The "" have to include an actual file.

--
-ed- em**********@noos.fr [remove YOURBRA before answering me]
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 13 '05 #11
qa********@rediffmail.com (qazmlp) wrote in message news:<db*************************@posting.google.c om>...
If I include the headers(.h files) like
#include "myHeader.h",
in my implementation file(.C file), then 'myHeader.h' is properly
included. But, when I include it like
#include <myHeader.h>, Compiler gives an error.

What setting do I need to do such that, the latter syntax also accepted
for my headers ?


Which of "myHeader.h" or <myHeader.h> works depends entirely on your
compiler. The ISO standard specifies that both ways search for headers
in an implementation-defined manner. It also says that if #include
"myHeader.h" fails (or is not supported), the line is reprocessed as
if it were read #include <myHeader.h>.

On the practical side, a compiler will search a header included with
quotes in the working directory, and will search where its settings
tell it to when included with <>.
Nov 13 '05 #12
Dave Uhring <da********@yahoo.com> wrote:
On Tue, 08 Jul 2003 19:28:11 +0000, Emmanuel Delahaye wrote:
This is completely implementation dependent.

The good reason was exposed already on the other posts.

<> -> implementation
"" -> user


Works the same way with gcc and Solaris cc. What is your point?


This is cross-posted to comp.lang.c. It's probably defined by the SUS or
POSIX or something similar, but in ISO C it's not even defined whether
you can put your own header files in the <> location; in fact, it isn't
even defined whether you, the user, can read the system header files.

Of course, said cross-post is evil, for precisely that reason.

Richard
Nov 13 '05 #13
On Wed, 09 Jul 2003 08:11:19 +0000, Richard Bos wrote:
Of course, said cross-post is evil, for precisely that reason.


Of course, that was cross posted to comp.unix.programmer,
comp.unix.solaris, and comp.lang.c

Evil is as evil does ;-)

Nov 13 '05 #14
Oleg Goldshmidt <pu*@NOSPAM.goldshmidt.org> writes:
The preprocessor will only search the system directories for the <>
headers (and there are probably options to modify the system search
path, for gcc/g++ it is -isystem). It will search a different path
(according to command line options again, for gcc/g++ it is -I) to
search for the "" files, and if none is found the system include path
will be searched. Note that the usage of -isystem and -I differs from
what you wrote, at least for gcc/g++.


Pathnames enclosed in "<>" are search with -I for all C compilers
I'm familiar with (the -isystem option is slightly different)/

Files enclosed in "" are first searched in the directory where the
file which includes them resides; then the ordinary <> search path
is used.

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Nov 13 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: qazmlp | last post by:
I need to include a list of - C++ headers - headers of other modules - headers of my module - implementation specific ie.OS headers In what order, they should be included in my .CPP file?...
18
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...
18
by: John Smith | last post by:
Hi all What does the group think of the practise of including one header file from inside another? I have some legacy code where this has been done, and it creates a dependency on a module...
8
by: nrhayyal | last post by:
Hi c++ Gurus, Need your blessing. while testing few aspects with respect to header file inclusions, i observed few things which i would like to share with you. i have a file sqlca.h in which a...
6
by: techBoy | last post by:
I am looking for a tool that can scan my soyrce code and check if a header file gets included more then once in a sequece of compiled code. Can some one guide me to such a tool !!
3
by: fc2004 | last post by:
Hi, Is there any tools that could report where cyclic header dependency happens? this would be useful when working with a large project where tens or hundreds of headers files may form complex...
12
by: Ben | last post by:
I'm kind of new to creating templates. I've made some small class and function templates in the past and I have used quite of bit of the STL, but I am having problems tyring to create templates. ...
4
by: Christoph Scholtes | last post by:
Hi, I have some questions about header files: Say I have a file functions.c which contains a couple of functions. I have declared some structs in this file too. The structs are defined in...
5
by: Rahul | last post by:
Hi, I often include the header files like the following, #include <string.h> However, i get a warning from the compiler to remove the .h and it works fine with the following, #include...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.