4

I need to embed Boost headers in my project.

According to this question, the recommendation would be to include using double-quote (#include "boost/filesystem.hpp") so that it doesn't use the system version of Boost if installed.

What is the behavior, according to the C++ standard and popular implementations, when these local headers include other headers with angle brackets (which appears to be the code style in Boost headers)?

Community
  • 1
  • 1
Warren Seine
  • 2,311
  • 2
  • 25
  • 38

1 Answers1

4

Most of the 'popular' implementations I've seen would include headers in quotes relative to the path of the source file being compiled with angle brackets searched relative to designated search paths for includes. As mentioned in that thread, the actual distinction between how compilers search for headers included in quotes as opposed to brackets is purely implementation-defined.

I wouldn't attempt to use quotes for a library like boost in hopes of avoiding conflicts with another installed version for the specific reason you pointed out. It includes its relative headers typically with angle brackets so your attempt to avoid using the wrong version of boost if two are installed is not something that would likely be solved by including a boost header in quotes just on your end.

Instead, you should probably look at the priority of include paths you specify to the compiler.

Edit: you should also look into the priority of your lib paths as well for static linking (thanks to James Kanze for the suggestion).

What is the behavior, according the the C++ standard and to popular implementations, when these local headers include other headers with angle brackets (which appears to be the code style in Boost headers)?

Typically the exact same behavior you'd expect if you included the headers yourself in angle brackets.

stinky472
  • 6,737
  • 28
  • 27
  • 3
    And the order of the library paths when linking as well. Using the headers from one version and the library from another is not likely to work very well. – James Kanze Feb 29 '12 at 18:10
  • With GCC, `-I` arguments are still searched before any other directory, whatever the `#include`-style. – Warren Seine Feb 29 '12 at 22:26