Sunteți pe pagina 1din 6

9/26/2016 #includedirective

CodeGuruHome VC++/MFC/C++ .NET/C# VisualBasic VBForums Developer.com

UserName Password Login Help Register


RememberMe?

Isyourbusinessanenergysap?LearnhowtosavemoneybymakingyourdatacenterrunefficientlywithoureBook.

Forum What'sNew?

NewPosts FAQ Calendar ForumActions QuickLinks AdvancedSearch

Forum VisualC++&C++Programming
C++(NonVisualC++Issues) #includedirective

Ifthisisyourfirstvisit,besuretocheckouttheFAQby
clickingthelinkabove.YoumayhavetoregisterorLogin
beforeyoucanpost:clicktheregisterlinkabovetoproceed.To
startviewingmessages,selecttheforumthatyouwanttovisit
fromtheselectionbelow.

Results1to7of7

Thread:#includedirective
Share 0 Share 0 Tweet
Share

ThreadTools Display

January12th,2004, 04:41AM #1

nsh123
Member

JoinDate: Dec2003
Posts: 99

#includedirective
Whatisthedifferencebetweenthefollowingto
statements:

1.#include<abc.h>

2.#include"abc.h"

Regards

ReplyWithQuote

January12th,2004, 04:58AM #2

http://forums.codeguru.com/showthread.php?278835includedirective 1/6
9/26/2016 #includedirective

VictorN
SuperModerator
PowerPoster

JoinDate: Jan2003
Location: Wallisellen(ZH),
Switzerland
Posts: 18,656

Hi!
AccordingtoMSDNThe#includeDirective:

....
#include"pathspec"

#include<pathspec>

Thepathspecisafilenameoptionally
precededbyadirectoryspecification.The ClickHeretoExpandForumtoFullWidth
filenamemustnameanexistingfile.The
syntaxofthepathspecdependsonthe
operatingsystemonwhichtheprogramis
compiled.
OneQuestionPoll(#031)

Bothsyntaxformscausereplacementofthat
directivebytheentirecontentsofthespecified
includefile.Thedifferencebetweenthetwo
formsistheorderinwhichthepreprocessor
searchesforheaderfileswhenthepathis 1.WhatType(s)ofApps
incompletelyspecified. areyouBuilding?
SyntaxFormAction
QuotedformThisforminstructsthe CloudServices
preprocessortolookforincludefilesinthe
samedirectoryofthefilethatcontainsthe Desktop
#includestatement,andtheninthe
directoriesofwhateverfilesthatinclude
Embedded
(#include)thatfile.Thepreprocessorthen
searchesalongthepathspecifiedbythe/I
compileroption,thenalongpathsspecifiedby IoT
theINCLUDEenvironmentvariable.
AnglebracketformThisforminstructsthe Mobile(Phone)
preprocessortosearchforincludefilesfirst
alongthepathspecifiedbythe/Icompiler
option,thenalongthepathspecifiedbythe
Mobile(Tablet)
INCLUDEenvironmentvariable.
Wearable

Thepreprocessorstopssearchingassoonas Web
itfindsafilewiththegivenname.Ifyou
specifyacomplete,unambiguouspath
specificationfortheincludefilebetweentwo WebServices
setsofdoublequotationmarks(""),the
preprocessorsearchesonlythatpath Other(pleasespecify)
specificationandignoresthestandard
directories.
....

ReplyWithQuote poweredby

ThisaCodeguru.comsurvey!
January12th,2004, 05:20AM #3

Graham
EliteMember
PowerPoster

JoinDate: Apr1999
http://forums.codeguru.com/showthread.php?278835includedirective 2/6
9/26/2016 #includedirective
Location: Altrincham,England
Posts: 4,471

AccordingtotheISOstandard(section16.2),

2Apreprocessingdirectiveoftheform

#include<hcharsequence>newline

searchesasequenceofimplementation
definedplacesforaheaderidentifieduniquely
bythespecifiedsequencebetweenthe<and
>delimiters,andcausesthereplacementof
thatdirectivebytheentirecontentsofthe
header.Howtheplacesarespecifiedorthe
headeridentifiedisimplementationdefined.

3Apreprocessingdirectiveoftheform

#include"qcharsequence"newline

causesthereplacementofthatdirectiveby
theentirecontentsofthesourcefileidentified
bythespecifiedsequencebetweenthe"
delimiters.Thenamedsourcefileissearched
forinanimplementationdefinedmanner.If
thissearchisnotsupported,orifthesearch
fails,thedirectiveisreprocessedasifitread

#include<hcharsequence>newline

withtheidenticalcontainedsequence
(including>characters,ifany)fromthe
originaldirective.

Inotherwords,thequotedformshouldalwaysfind
aheaderthatthe<>formwould,butnottheother
wayaround.

Inpractice,usethe<>formforsystemheaders
andthequotedformforapplicationspecific
headers.

Correct is better than fast. Simple is better than complex.


Clear is better than cute. Safe is better than insecure.
Sutter and Alexandrescu, C++ Coding Standards

Programs must be written for people to read, and only


incidentally for machines to execute.
Harold Abelson and Gerald Jay Sussman

The cheapest, fastest and most reliable components of a


computer system are those that aren't there.
Gordon Bell

ReplyWithQuote

January12th,2004, 06:52AM #4

nsh123
Member

JoinDate: Dec2003
Posts: 99

http://forums.codeguru.com/showthread.php?278835includedirective 3/6
9/26/2016 #includedirective

Inotherwords,thequotedformshould
alwaysfindaheaderthatthe<>formwould,
butnottheotherwayaround.

Inpractice,usethe<>formforsystem
headersandthequotedformforapplication
specificheaders.

Thanksall,
Iamusingalibraryinmyproject.WhenIbuildit
indebugmodeitbuildsfine.ButwheninReleease
modetheheaderfilesarenotfound!!!Ifigive
absolutepathitworks.
The"includedirectories"forboththeconfigurations
isthesame.

Theproblemissolvedbyreplacing#include"lib.h"
by#include<lib.h>?

ThelibraryisathirdpartythingIonlyhavethe
headers.

Regards

ReplyWithQuote

January12th,2004, 10:59AM #5

CJ1
Member

JoinDate: Dec2003
Location: Montreal
Posts: 58

Becausethesearchisimplementationdefined,you
willneedtoconsultthecompiler'sdocumentation
toseehowitimplementseachformat.

Ifitworksindebugbutnotrelease,youhave
differentsettingsforeachsowhenyouchangeone,
itisnotreflectedintheotherunlesyoudidso
specifically,updatethereleasesettings.

Makesureyourincludepathisthesameforboth
debugandrelease.Asagoodruleofthumb,use
the<>formatwhentheheaderfileisnot
containedwithinyouproject'sdirectorystructure,
andusethe""formatwhenitis.

ReplyWithQuote

January13th,2004, 01:56AM #6

nsh123
Member

JoinDate: Dec2003
Posts: 99

Thanks

Makesureyourincludepathisthesamefor
bothdebugandrelease.Asagoodruleof
http://forums.codeguru.com/showthread.php?278835includedirective 4/6
9/26/2016 #includedirective

thumb,usethe<>formatwhentheheader
fileisnotcontainedwithinyouproject's
directorystructure,andusethe""format
whenitis.

AsIsaid"includedirectories"forboththeconfigs
isthesame
AnyotherparameterthatIshouldcheck.

Thoughthesearchmethodorsequenceisdifferent
bothmustalwayssearchincludedirectoriesright?

Regards
Lasteditedbynsh123January13th,2004at01:59AM.

ReplyWithQuote

January13th,2004, 08:02AM #7

galathaea
SeniorMember

JoinDate: Sep2002
Posts: 1,747

Often,theincludedirectoryissetperbuildtype.
Maybeyoujusthaven'tsetyourincludedirectory
properlyforrelasebuild?

*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/

"It'shardtobelieveinsomethingyoudon't
understand."thesidhiXfilesepisode

galathaea:prankster,fablist,magician,liar

ReplyWithQuote

QuickNavigation C++(NonVisualC++Issues) Top

PreviousThread|NextThread

PostingPermissions
Youmaynot BBcodeis
postnew On
threads Smiliesare
Youmaynot On
postreplies [IMG]code
Youmaynot isOn
post [VIDEO]
attachments codeisOn
Youmaynot HTMLcode
edityourposts isOff

Forum
Rules

ContactUs CodeGuruForums PrivacyStatement Top


http://forums.codeguru.com/showthread.php?278835includedirective 5/6
9/26/2016 #includedirective

BlueCodeguru

AcceptableUsePolicy

PropertyofQuinStreetEnterprise.
Terms of Service| Licensing & Reprints| Privacy Policy| Advertise
Copyright 2016 QuinStreet Inc. All Rights Reserved.
AlltimesareGMT5.Thetimenowis07:35AM.

CopyrightQuinstreetInc.20022016

http://forums.codeguru.com/showthread.php?278835includedirective 6/6

S-ar putea să vă placă și