Comment by alextingle

2 days ago

>> `#include "base/pc.h"`, where that `"base/pc.h"` path is not relative to the file doing the include.

> I have to disagree on this one.

The double-quotes literally mean "this dependency is relative to the current file". If you want to depend on a -I, then signal that by using angle brackets.

Eh, no. The quotes mean "this is not a dependency on a system library". Quotes can include relative to the files, or they can include things relative to directories specified with -I. The only thing they can't is include things relative to directories specified with -isystem and system include directories.

I would be surprised if I read some project's code where angle brackets are used to include headers from within the same project. I'm not surprised when quotes are used to include code from within the project but relative to the project's root.

  • The only difference between "" and <> is that the former adds the current file's directory to the beginning of the search path.

    So the only reason to use "" instead of <> is when you need that behaviour, because the dependency is relative to the current file.

    If you use "" in any other situation, then you are introducing a potential error, because now someone can change the meaning of your code simply by creating a file with a name and location that happens to match your dependency.

    (Yes, some compilers have -isystem and -iquote which modify that behaviour, but those options are not standard, and can't be relied upon. I'd strongly advise against their use.)