Opened 6 years ago

Closed 5 years ago

#12639 closed Bugs (fixed)

Boost.Spirit + BOOST_DISABLE_THREAD problem

Reported by: anonymous Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:

Description

While updating the version of Boost used by some older code, I ran into a compiler-error with respect to Boost.Spirit. My code is explicitly defining 'BOOST_DISABLE_THREAD' to avoid linking in the threading library.

I tracked down the error to line 13 of https://github.com/boostorg/spirit/blob/develop/include/boost/spirit/home/classic/utility/scoped_lock.hpp

In the latest check-in (July 2015), the "#include <boost/thread/lock_types.hpp>" line was added. This line causes a compile error when 'BOOST_DISABLE_THREAD' is defined. (It indirectly includes other headers which 'require' the Boost.Thread library.)

I would blindly suggest that wrapping line 13 in a "#ifndef BOOST_DISABLE_THREAD" seems to solve the problem?

Change History (2)

comment:1 by Nikita Kniazev <nok.raven@…>, 5 years ago

It is pointless to ifdef threads include as it will hide a real problem and you will receive other error if you use scoped_lock with BOOST_DISABLE_THREAD.

I guess you use #include <boost/spirit/include/classic.hpp> and it includes boost/spirit/home/classic/utility/scoped_lock.hpp even if BOOST_SPIRIT_THREADSAFE is not defined, so I think it should be fixed like this https://github.com/boostorg/spirit/pull/323.

comment:2 by Joel de Guzman, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.