Original Post
What is the difference between the two formats
#include
and
#include "abc.h"
?
Please explain!
#include
and
#include "abc.h"
?
Please explain!
Short story: The angle bracket version is for external header files, the quotation marks are for your own header files. See here for a full explanation.
Please look in the standard!
The standard is no place for an inexperienced programmer.
[/quote]
Incorrect replies like yours have no place at all. The short story is that it is implementation defined where each of these look for files and even that they may look in the same place.
Please look in the standard!
Do you own a copy of C++ standard? Not draft, the actual copy.
Please look in the standard!
Q: "How do I turn on the headlights?"
A: "Please consult Feynman's 4-part works on physics"
[/quote]
Where are the headlights?
As for
[color=#1C2837][size=2]The standard is no place for an inexperienced programmer. [/quote]
[color=#1C2837][size=2]I consider this wrong but if the user had posted in "For Beginners" then maybe I would have answered differently
Me? Yes thanks, is there a difference between the draft and the final here IIRC the C++ standard uses pretty much the same word for word description as C99.
Where are the headlights?[/quote]
Please consult the traffic legislation regulating the automobile industry relevant to your jurisdiction.
Incorrect replies like yours have no place at all.
The standard is no place for an inexperienced programmer.
[/quote]
I consider this wrong but if the user had posted in "For Beginners" then maybe I would have answered differently
[/quote]
Why don't we just close every pure C++ thread - since the correct answers are all in the standard.
[color="#1C2837"]Why don't we just close every pure C++ thread - since the correct answers are all in the standard. [/quote]
[color="#1C2837"]That sounds like an excellent idea but what in the OP's post says it is C++?
OK this thread confuses me somewhat. Factually incorrect information gets voted up and factually correct information which asks the lazy OP to do some leg work themselves gets voted down? With a post about headlights also getting voted up. Erm let me check again is this the Lounge!
[color="#1c2837"]That sounds like an excellent idea but what in the OP's post says it is C++?
[/quote]
It's not an unreasonable assumption to make that the OP might have been talking about C++. But rip-off's point stands with any language. These boards would be a barren place if no one was allowed to ask questions because the answer might be (or even definitely is) in some expensive document. Going further, why even teach programming in classes? People can just read the language specs and then fend for themselves.
If you feel that a question is beneath you, an easy way to avoid having the poster waste your time with their ignorance is to just not respond.
I see. What gamedev wants is damn right lazy people posting lazy questions that do not show they have tried to find the answer for themselves. I think you will find my answer to look in the standard is net etiquette for lazy bastards wanting information ie RTFM. To imply that I was rude or anything even close I find an insult, look again at my post it twice uses the word please and even requests that if the standard is not understood then ask another question.
I would like you to clarify where I was "Aggressive, combative, [or] rude " but never mind all is well, I do not need gamedev just as much as it seems the gamedev community does not want correct answers.
Please look in the standard!
If you have a question after that then please post it.
Incorrect replies like yours have no place at all. The short story is that it is implementation defined where each of these look for files and even that they may look in the same place.
OK this thread confuses me somewhat. Factually incorrect information gets voted up and factually correct information which asks the lazy OP to do some leg work themselves gets voted down? With a post about headlights also getting voted up. Erm let me check again is this the Lounge!
[color="#1c2837"]Why don't we just close every pure C++ thread - since the correct answers are all in the standard. [/quote]
[color="#1c2837"]That sounds like an excellent idea but what in the OP's post says it is C++?
[/quote]
Combative and petulant. As I mentioned above, the particular language chosen is irrelevant to rip-off's comment. An unnecessary comment to anything that came before which can only be response to rip-off's comment if you totally miss the content of what he said.
I see. What gamedev wants is damn right lazy people posting lazy questions that do not show they have tried to find the answer for themselves. I think you will find my answer to look in the standard is net etiquette for lazy bastards wanting information ie RTFM. To imply that I was rude or anything even close I find an insult, look again at my post it twice uses the word please and even requests that if the standard is not understood then ask another question.
Expecting someone to at least try looking something up first is indeed reasonable etiquette. Asking a basic question without such an attempt is not. But someone else displaying less than perfect etiquette is no reason to conduct yourself even more objectionably, which you quickly descended to.
Your initial reply was not really rude, as discussed above, but also directed the OP to a document which he may or may not have had available to him, and is quite long and dense besides. It's unfortunate that you feel insulted by my impression of your tone in this thread. But if you re-read it, do you really feel as though you were nothing but polite and reasonable throughout?
I would like you to clarify where I was "Aggressive, combative, [or] rude " but never mind all is well, I do not need gamedev just as much as it seems the gamedev community does not want correct answers.
[/quote]
See above for the requested clarifications. I did not say that you yourself were all of those all the time, or that you are an example of the worst of them or even a particularly bad example. Just that such behavior invites downvotes, because it is discouraged by the community. You have several downvotes in this thread, and as you said your information is not incorrect, so they can't be from that. That leaves your comportment.
As for leaving gamedev, we'll be sorry to see you and your expertise go. But you are as free to stop coming at any time as you are to simply not respond to threads and questions that annoy you.
Short story: The angle bracket version is for external header files, the quotation marks are for your own header files. See here for a full explanation.
It seems to be troll's month, meh.
includes with < > is to load include files relative the include directory you tell your compiler to look up for. (in VS there is a configuration option that is Include Directory or something). (-I from the command line?)includes with "" is to load include files relative to your project's directory.
Reputation of 1000+ equals helpfull.
Reputation of 0 equals unhelpfull.
6.10.2 Source file inclusion
Constraints
1 A #include directive shall identify a header or source file that can be processed by the implementation.
Semantics
2 A preprocessing directive of the form
# includenew-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
# includenew-line with the identical contained sequence (including > characters, if any) from the original
directive.
142) As indicated by the syntax, a preprocessing token shall not follow a #else or #endif directive before the terminating new-line character. However, comments may appear anywhere in a source file, including within a preprocessing directive.
§6.10.2 Language 149
7
8
EXAMPLE 1 The most common uses of #include preprocessing directives are as in the following: #include
#include "myprog.h" EXAMPLE 2 This illustrates macro-replaced #include directives:
#if VERSION == 1 #define INCFILE "vers1.h"
#elif VERSION == 2 #define INCFILE "vers2.h" // and so on
#else
#define INCFILE "versN.h" #endif
#include INCFILE
Forward references: macro replacement (6.10.3).
143) Note that adjacent string literals are not concatenated into a single string literal (see the translation phases in 5.1.1.2); thus, an expansion that results in two string literals is an invalid directive.
ISO/IEC 9899:1999 (E) ©ISO/IEC
4 A preprocessing directive of the form
# include pp-tokens new-line
(that does not match one of the two previous forms) is permitted.(OO who would have thought) The preprocessing tokens after include in the directive are processed just as in normal text. (Each identifier currently defined as a macro name is replaced by its replacement list of preprocessing tokens.) The directive resulting after all replacements shall match one of the two previous forms.143) The method by which a sequence of preprocessing tokens between a < and a > preprocessing token pair or a pair of " characters is combined into a single header name preprocessing token is implementation-defined.
5 The implementation shall provide unique mappings for sequences consisting of one or more letters or digits (as defined in 5.2.1) followed by a period (.) and a single letter. The first character shall be a letter. The implementation may ignore the distinctions of alphabetical case and restrict the mapping to eight significant characters before the period.
6 A #include preprocessing directive may appear in a source file that has been read because of a #include directive in another file, up to an implementation-defined nesting limit (see 5.2.4.1).[/quote] C++ 2003
16.2 Source file inclusion [cpp.include]
1 A #include directive shall identify a header or source file that can be processed by the implementation. 2 A preprocessing directive of the form
# includenew-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
# includenew-line with the identical contained sequence (including > characters, if any) from the original directive.
4 A preprocessing directive of the form # include pp-tokens new-line
(that does not match one of the two previous forms) is permitted(And again OOOO). The preprocessing tokens after include __________________ 138) Thus, the constant expression in the following #if directive and if statement is not guaranteed to evaluate to the same value in these two contexts.
#if ’z’ - ’a’ == 25 if (’z’ - ’a’ == 25)
139) As indicated by the syntax, a preprocessing token shall not follow a #else or #endif directive before the terminating new-line character. However, comments may appear anywhere in a source file, including within a preprocessing directive.
309
ISO/IEC 14882:2003(E) ? ISO/IEC 16.2 Source file inclusion 16 Preprocessing directives
in the directive are processed just as in normal text (each identifier currently defined as a macro name is replaced by its replacement list of preprocessing tokens). If the directive resulting after all replacements does not match one of the two previous forms, the behavior is undefined.140) The method by which a sequence of preprocessing tokens between a < and a > preprocessing token pair or a pair of " characters is combined into a single header name preprocessing token is implementation-defined.
5 The mapping between the delimited sequence and the external source file name is implementation-defined. The implementation provides unique mappings for sequences consisting of one or more nondigits (2.10) followed by a period (.) and a single nondigit. The implementation may ignore the distinctions of alpha- betical case.
6 A #include preprocessing directive may appear in a source file that has been read because of a #include directive in another file, up to an implementation-defined nesting limit.
7 [Example: The most common uses of #include preprocessing directives are as in the following: #include
#include "myprog.h"
—end example]
[/quote]
[color="#1c2837"]And finally
[color="#1c2837"][color=#1C2837][size=2]Bye![/quote]
[color=#1C2837][size=2]Correct
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more