Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > #include with "" or <>

Reply
Thread Tools

#include with "" or <>

 
 
Sebastian Faust
Guest
Posts: n/a
 
      05-11-2007
Hi,

I hava a somehow strange problem. I hope I am not wrong in this group;
if this is the case please let me know.

I am trying to compile a rather simple C program. As long as I use:
#include <extp.h>
gcc tells me that he cannot find extp.h.
As soon as I write
#include "extp.h"
the compiling continues. Unfortunately, in extp.h there are again
#includes that use <> so I get a similar error later on during the
compiling process. Probably it is a problem with the environment
variables or paths.

Thanks for your help!
Sebastian

 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      05-11-2007
Sebastian Faust said:

> Hi,
>
> I hava a somehow strange problem. I hope I am not wrong in this group;
> if this is the case please let me know.
>
> I am trying to compile a rather simple C program. As long as I use:
> #include <extp.h>
> gcc tells me that he cannot find extp.h.
> As soon as I write
> #include "extp.h"
> the compiling continues.


Use the "myheader.h" form for headers you create yourself. For standard
headers and any headers supplied by the implementation, use the
<implementationsuppliedheader.h> form instead.

> Unfortunately, in extp.h there are again
> #includes that use <> so I get a similar error later on during the
> compiling process.


If those are standard headers, you have a problem. Otherwise, see above.

> Probably it is a problem with the environment variables or paths.


If so, ask in a gcc group.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
 
 
 
Thomas Dickey
Guest
Posts: n/a
 
      05-11-2007
Richard Heathfield <> wrote:

> If so, ask in a gcc group.


actually almost any newsgroup where people develop with C.
This is not one of those groups.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
 
Reply With Quote
 
Laurent Deniau
Guest
Posts: n/a
 
      05-11-2007
Sebastian Faust wrote:
> Hi,
>
> I hava a somehow strange problem. I hope I am not wrong in this group;
> if this is the case please let me know.
>
> I am trying to compile a rather simple C program. As long as I use:
> #include <extp.h>
> gcc tells me that he cannot find extp.h.
> As soon as I write
> #include "extp.h"
> the compiling continues. Unfortunately, in extp.h there are again
> #includes that use <> so I get a similar error later on during the
> compiling process. Probably it is a problem with the environment
> variables or paths.


add the option -I. to your compiler command line invocation.

a+, ld.
 
Reply With Quote
 
Bart van Ingen Schenau
Guest
Posts: n/a
 
      05-11-2007
Sebastian Faust wrote:

> Hi,
>
> I hava a somehow strange problem. I hope I am not wrong in this group;
> if this is the case please let me know.
>
> I am trying to compile a rather simple C program. As long as I use:
> #include <extp.h>
> gcc tells me that he cannot find extp.h.
> As soon as I write
> #include "extp.h"
> the compiling continues. Unfortunately, in extp.h there are again
> #includes that use <> so I get a similar error later on during the
> compiling process. Probably it is a problem with the environment
> variables or paths.


More likely, it is a problem with not understanding the difference
between #include <x> and #include "x".

The #include <x> form is meant for system headers, so the compiler will
only look in those places where it knows that system headers are
stored.
The #include "x" form, on the other hand, is meant for user headers.
With this form, the compiler will first look in the current directory.
If the header can not be found there, the search continues as if the
form #include <x> was used.

If the extp.h file is part of the current project, then you should
rewrite the header to use the #include "x" notation for non-system
headers (and for including the file itself in the source code).

If the extp.h file belongs to an external library, then you could tell
the compiler to add the directory where it resides to the search path
for system headers. How to do this is compiler dependent and should be
documented in the compiler documentation/help-file.

>
> Thanks for your help!
> Sebastian


Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://www.eskimo.com/~scs/C-faq/top.html
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      05-11-2007
Thomas Dickey said:

> Richard Heathfield <> wrote:
>
>> If so, ask in a gcc group.

>
> actually almost any newsgroup where people develop with C.


No, if his implementation is misconfigured, the best group in which to
seek help is one which discusses his implementation.

> This is not one of those groups.


Your cynicism is misplaced.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
Thomas Dickey
Guest
Posts: n/a
 
      05-12-2007
Richard Heathfield <> wrote:
> Thomas Dickey said:


>> Richard Heathfield <> wrote:
>>
>>> If so, ask in a gcc group.

>>
>> actually almost any newsgroup where people develop with C.


> No, if his implementation is misconfigured, the best group in which to
> seek help is one which discusses his implementation.


Since you didn't bother to even obliquely reference the C standard which
points out

A preprocessing directive of the form

# include "q-char-sequence" new-line

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

your comment was non-responsive. If you'd made the same comment in
comp.unix.programmer, it would have been just as non-responsive (for
different reasons of course

>> This is not one of those groups.


> Your cynicism is misplaced.


As long as you make responses such as you did, then it's a valid comment.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      05-12-2007
Thomas Dickey said:

> Richard Heathfield <> wrote:
>> Thomas Dickey said:

>
>>> Richard Heathfield <> wrote:
>>>
>>>> If so, ask in a gcc group.
>>>
>>> actually almost any newsgroup where people develop with C.

>
>> No, if his implementation is misconfigured, the best group in which
>> to seek help is one which discusses his implementation.

>
> Since you didn't bother to even obliquely reference the C standard
> which points out


I suggest you read my reply again, this time paying attention to the
actual words. I refer you particularly to the paragraph in which I
said:

"Use the "myheader.h" form for headers you create yourself. For standard
headers and any headers supplied by the implementation, use the
<implementationsuppliedheader.h> form instead."

and which you unaccountably appear to have missed.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
Thomas Dickey
Guest
Posts: n/a
 
      05-12-2007
Richard Heathfield <> wrote:
> Thomas Dickey said:


>> Richard Heathfield <> wrote:
>>> Thomas Dickey said:

>>
>>>> Richard Heathfield <> wrote:
>>>>
>>>>> If so, ask in a gcc group.
>>>>
>>>> actually almost any newsgroup where people develop with C.

>>
>>> No, if his implementation is misconfigured, the best group in which
>>> to seek help is one which discusses his implementation.

>>
>> Since you didn't bother to even obliquely reference the C standard
>> which points out


> I suggest you read my reply again, this time paying attention to the
> actual words. I refer you particularly to the paragraph in which I
> said:


> "Use the "myheader.h" form for headers you create yourself. For standard
> headers and any headers supplied by the implementation, use the
> <implementationsuppliedheader.h> form instead."


> and which you unaccountably appear to have missed.


no - I read it (otherwise there's no point in a followup).
You mention the two varieties (which are in OP's comment).

But the advice given needs qualification to be useful (there's no mention
that generally compiler options are needed to make it work properly).

Furthermore, it's flawed (that implementation-specific area covers several
pitfalls). My experience is that the best practice is to use quoted
includes only for cases where nested inclusion is not used, for instance.
Otherwise different implementations produce different results for the
search path (all of course disclaimed in the standard as implementation
specific behavior).

btw - this comment:

>No, if his implementation is misconfigured, the best group in which to
>seek help is one which discusses his implementation.


could be taken to imply that he might want to reinstall his compiler
by suggesting there's something amiss with the configuration.

and this comment;

>If so, ask in a gcc group.


can be interpreted as suggesting that OP follow up on gnu.gcc.bug
or gnu.gcc.help (thinking about it, I guess you did mean for OP to
spend time reinstalling the compiler

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      05-12-2007
Thomas Dickey said:

> Richard Heathfield <> wrote:
>> Thomas Dickey said:

>

<snip>
>>> Since you didn't bother to even obliquely reference the C standard
>>> which points out

>
>> I suggest you read my reply again, this time paying attention to the
>> actual words. I refer you particularly to the paragraph in which I
>> said:

>
>> "Use the "myheader.h" form for headers you create yourself. For
>> standard headers and any headers supplied by the implementation, use
>> the <implementationsuppliedheader.h> form instead."

>
>> and which you unaccountably appear to have missed.

>
> no - I read it (otherwise there's no point in a followup).
> You mention the two varieties (which are in OP's comment).
>
> But the advice given needs qualification to be useful


Then feel free to qualify it, by all means - that's a great reason for a
follow-up - but please don't pretend I didn't write it in the first
place.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments