[vtkusers] " " vs < > for includes

Julien Lamy lamy at unistra.fr
Thu Nov 19 10:49:47 EST 2009


David Doria a écrit :
> I noticed that most of the includes are done like this:
> #include "vtkPolyData.h"
> 
> Don't the quotes mean "look in the current directory", where
> #include <vtkPolyData.h>
> 
> means "look on the PATH"?

According to the C standard, the <something.h> form searches in a list
of implementation-defined places. The "something.h" searches in
/another/ list of implementation-defined places, and if the file is not
found, proceeds as for the <something.h> form (cf.
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf, page 161).

The specific behavior for gcc is there :
http://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html

> If this is correct, shouldn't they all use <> since we want to find
> headers in all of the subdirectories (VTK/Graphics, VTK/Filtering,
> etc), which I assume have been put on a header_path type variable by
> cmake?
> 
> It clearly works the way it is and I'm sure it is "correct" since the
> whole project does it like this, I was just curious.

Since the places searched by the "something.h" form is a superset of the
<something.h> form, the "correct" way of doing is, in my opinion, just a
matter of conventions. What I've seen most of the time is to use the
quote form for files local to the project and the bracket form for
external files.



More information about the vtkusers mailing list