473,405 Members | 2,176 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,405 software developers and data experts.

Preprocessor includes, difference between quote and lt/gt

Hi.

What's the practical difference between:

#include <header.h>

and:

#include "header.h"

...besides the fact that in the second case, 'header.h' will be used if
it's
in the current working directory?

cheers,
MC

Nov 30 '06 #1
3 2126
ar**********@googlemail.com said:
Hi.

What's the practical difference between:

#include <header.h>

and:

#include "header.h"

3.1.7 of C89 says (in part): "The sequences in both forms of header names
are mapped in an implementation-defined manner to headers or external
source file names as specified in $3.8.2."

3.8.2 says (in part): " A preprocessing directive of the form

# include <h-char-sequence new-line

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.

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

# include <h-char-sequence new-line

with the identical contained sequence (including characters, if any)
from the original directive.
So the practical upshot is that C provides two different mechanisms for
finding a header: "header" and <header>. If you use "header", the
implementation uses a particular search strategy, which could of course
fail. If it does, the implementation pretends you'd used <headerinstead,
which also uses a particular search strategy for locating the header. There
need not necessarily be any difference between the two strategies, but on
typical desktop systems there normally is. (I know of no typical desktop
exceptions, anyway.)

..besides the fact that in the second case, 'header.h' will be used if
it's
in the current working directory?
A mere implementation detail, of no particular significance in comp.lang.c -
the C language does not require implementations to support or even
recognise a concept of "directory", and some implementations do not in fact
recognise such a concept.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Nov 30 '06 #2
Ok, thanks. That explains it well.

MC

Nov 30 '06 #3
ar**********@googlemail.com wrote:
>
What's the practical difference between:

#include <header.h>
and:
#include "header.h"

..besides the fact that in the second case, 'header.h' will be
used if it's in the current working directory?
Not so. Look at your system documentation. Note that <header.h>
need not access any file whatsoever. What the standard says is
(N869):

[#2] A preprocessing directive of the form

# include <h-char-sequencenew-line

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 "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

# include <h-char-sequencenew-line

with the identical contained sequence (including >
characters, if any) from the original directive.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Dec 1 '06 #4

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

Similar topics

205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
0
by: Johnny Willemsen | last post by:
Hi, I have an issue with the preprocessor of Visual Age. I have A.h that includes B.h that includes C.h. When B.h now only contains includes, it is not listed in the preprocessor output as file,...
13
by: Chris Croughton | last post by:
Is the following code standard-compliant, and if so what should it do? And where in the standard defines the behaviour? #include <stdio.h> #define DEF defined XXX int main(void) { int...
3
by: ashwani | last post by:
Hi Can any one tell me the difference between preprocessor macros like #define and enum. If i want to define MAX_LIMIT=100 as preprocessor macro as #define MAX_LIMIT 100 or if i define enum...
6
by: Amigo | last post by:
Hello all! I started working on an embedded project a few ago on Freescale 16-bit micro with an IAR toolset. Running PolySpace for the project code highlighted amongst other things a peculiar...
31
by: Sam of California | last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing of the source file"? I responded to that comment by saying that the preprocessor is not just a pass. It processes...
9
by: wenmang | last post by:
Hi, all: I have a question regarding to how to solve following problem: I have header called myHeader.h which #define MAX_LEN 100 (legacy code). Now, I like to put most commonly used in...
36
by: anon.asdf | last post by:
Hello! Can the proprocessor make conditional decisions. Here's an example of the functionality (not standard C!) #define PUT_BYTE(const_index, val) \ #preprocessor_if (const_index ==...
14
by: lagman | last post by:
All, I'm looking for a tool that is able to take my code base (which is full of preprocessor directives) and spit out source code that is "clean" of any preprocessor directives based on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...
0
isladogs
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 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.