V
Victor Bazarov
Exits Funnel said:I'm slightly confused about when to use parens around #included files
You're not alone.
and when to use angle brackets. I understand (I think) that the
difference is that the compiler will search in its standard include
directories for files included as <file> but not for those included as
"file". It's clear to me then that headers for the standard libraries
(eg, iostream) should be included using the '#include <iostream>' form
while header files for the classes I write should be included as '#include
"myheader.h"'.
Both forms cause implementation-defined behaviour. Whatever you know
about what actually happens is specific to your compiler. Another
compiler is free to behave differently. It has to document it, however.
I'm not so sure though for the cases in between. For example what if I
purchase a third party library. Which form should I use to include its
headers? Are there any hard and fast rules? Any conventions? Thanks in
advance for any replies.
It's all driven by the compiler rules. Read the documentation for your
compiler, it should explain those details. Most compilers I used did
have <> for searching in "predefined places", but VC++, for example, will
search for "" in those places, too.
Recently I've read some things about the differences, alleging that <>
(angle brackets) are reserved for the compiler headers. AFAICT it's not
necessarily so, and even if it is so in the Standard, all compilers I've
used do allow you to have your own header [file] and define its name in
the angle brackets. To me that means there is no rule saying that <>
should only name headers and never user's files.
V