BOOST_THREAD_USES_CHRONO not consistent on build and use
- Dominant language
- C++
- Stars
- 214
- Forks
- 171
- PR merge metrics
- No merged PRs in 30d
Description
As reported in https://github.com/boostorg/boost_install/issues/27, the following program:
```
#include
int main() {
boost::condition_variable cv;
boost::mutex mutex;
boost::unique_lock lock(mutex);
cv.wait_for(lock, boost::chrono::seconds(1));
return 0;
}
```
compiles on Linux but doesn't link without specifying `-lboost_chrono`, even though the Boost.Thread build/Jamfile doesn't specify Chrono as a dependency on Pthread platforms. The reason is that the Jamfile defines `BOOST_THREAD_DONT_USE_CHRONO` on Pthread platforms when Boost.Thread is built. However, when Boost.Thread is used by user code, `BOOST_THREAD_DONT_USE_CHRONO` is not defined and https://github.com/boostorg/thread/blob/develop/include/boost/thread/detail/config.hpp#L143 defines `BOOST_THREAD_USES_CHRONO`. This enables the `wait_for` overload and allows the code above to compile, even though the compiled library wasn't built with `BOOST_THREAD_USES_CHRONO`.
I'm not sure whether this behavior can be considered correct. One may argue that `BOOST_THREAD_USES_CHRONO` should not be defined on Pthread platforms by default, to match the settings with which the library is built.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.