Include local files

I need to embed Boost headers in my project.

According to this question, the recommendation will include the use of double quotes ( #include "boost/filesystem.hpp" ) so that it does not 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 looks like the code style in Boost headers)?

+4
source share
1 answer

Most of the โ€œpopularโ€ implementations I have seen will include quotation headers relative to the path of the source file compiled with angle brackets, searching for given search paths for inclusions. As mentioned in this thread, the actual difference between how compilers look for headers enclosed in quotation marks, unlike brackets, is purely an implementation.

I would not use quotes for a library like boost in the hope of avoiding conflicts with another installed version for the specific reason you specified. It includes its relative headers, usually with angle brackets, so your attempt to avoid using the wrong version of boost, if installed, is not something that will probably be allowed to include the boost header in quotation marks only at your end.

Instead, you should probably look at the priority of the included paths that you specify for the compiler.

Edit: You should also consider the priority of your lib paths, as well as for static linking (thanks to James Kansa for the suggestion).

What is the behavior according to the C ++ standard and popular when these local headers include other headers with (which looks like the code style in Boost headers)?

Typically, you would expect the same behavior if you included headings in angle brackets.

+4
source

Source: https://habr.com/ru/post/1399052/


All Articles