473,795 Members | 2,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2158
ar**********@go oglemail.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 <headerinstea d,
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**********@go oglemail.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
10720
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
1220
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, it only lists C.h, not even A.h. Does someone know why this is not listed in the preprocessor output with Visual Age? Maybe this can be enabled in some way? Regards
13
2137
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 defined = 2;
3
11670
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 {MAX_LIMIT=100}; then what is the basic difference? Is there any efficiency tradeoff between both the definitions.
6
15204
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 construct in one of the compiler's header files. Here's the code snippet: #ifndef __SIZE_T_TYPE__ #if sizeof((char*)0 - (char*)0) <= sizeof(int) #define __SIZE_T_TYPE__ unsigned int
31
2938
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 statements that the compiler does not process. The good people in the alt.comp.lang.learn.c-c++ newsgroup insist that the preprocessor is just one of many passes. The preprocessor processes a grammer unique to the preprocessor and only that grammer. ...
9
2337
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 myHeader.h into a namespace, e.g., #include <myHeader.h> namespace myNamespace {
36
2130
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 == 0) \ ({ *(77) = (val); }) \ #preprocessor_else_if (const_index == 1) \ ({ *(99) = (val); }) \
14
2603
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 options I choose (possibly via some kind of user input screen). Does such a tool exist? A Visual Studio plugin would be even better. FYI: I have requirements to rid my code of all conditionally compiled
0
9672
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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 we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.