Modify

Opened 16 months ago

Closed 2 months ago

#12053 closed Bugs (fixed)

boost include directives use double quotes incorrectly

Reported by: johnmaddock Owned by: apolukhin
Milestone: Boost 1.64.0 Component: any
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:

Description

Extracted from issue https://svn.boost.org/trac/boost/ticket/11516:

Many Boost headers use double-quoted include directives with paths that are not relative to the current header file. For example, this is an excerpt from boost/aligned_storage.hpp:

#include "boost/config.hpp" #include "boost/detail/workaround.hpp"

This will cause the full search path to be searched for the given files, even the directories supposedly local to the application (set via -iquote option on GCC/Clang), which can make local files interfere with Boost, especially if there's some part in the local project that is also called "boost"...

See a full list of offending directives via:

find /usr/include/boost -type f -exec grep '#.*"boost/' {} +

As can be seen in boost/any.hpp, this might even be intentional for boost/config.hpp, but this is surely not intended for any other file. Handling of boost/config.hpp is not uniform, however; see for example boost/limits.h, which includes config.hpp via angle-quotes.

This bug report does not address double-quoted include directives with header-relative paths, as used copiously by Boost Spirit, for example. These work fine on GCC/Clang and do not interact with local code (but see #3762).

I suggest to change all include directives to a uniform style in order to eliminate interference of local files. The easiest and least-invasive solution would be to change double quotes to angle brackets, something along the lines of

find /usr/include/boost -type f -exec sed -i~ -e 's/\(#.* \)"\(boost\/.*\)"/\1<\2>/' {} +

(warning: search-and-destroy capability; this also updates #defines that are used later in #include directives)

After applying this command, my code still compiles and passes all unit tests, but strace confirms that project-local include directories are no longer searched, except for boost/mpl/aux_/preprocessed/gcc/*.hpp, which is due to some stringification macro magic in boost/mpl/aux_/include_preprocessed.hpp. That's probably obscure enough to not matter in practice.

Attachments (0)

Change History (3)

comment:1 Changed 6 months ago by apolukhin

  • Owner changed from nasonov to apolukhin
  • Status changed from new to assigned

Fixed in develop in commit e6d8a49e. Will be merged to master as soon as tests pass.

comment:2 Changed 5 months ago by apolukhin

  • Milestone changed from To Be Determined to Boost 1.64.0

comment:3 Changed 2 months ago by apolukhin

  • Resolution set to fixed
  • Status changed from assigned to closed

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain apolukhin.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.