Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC + boost 1.70 compilation error when windows.h is already included (detail/thread_mutex.hpp) #116

Closed
mrpi opened this issue Apr 17, 2019 · 1 comment

Comments

@mrpi
Copy link

commented Apr 17, 2019

There is an ADL problem with boost 1.70.0 that did not occur for us with 1.67.0.

When BOOST_USE_WINDOWS_H is not defined but windows.h has already been included, the calls to InitializeCriticalSection(Ex), EnterCriticalSection, LeaveCriticalSection and DeleteCriticalSection are ambiguous.

I have pasted the problematic part on godbold where you can see the bug:
Godbolt of bug
If you uncomment the line //#define WORKAROUND a simple fix is applied.

file with error: detail/thread_mutex.hpp

error C2668: 'boost::container::dtl::InitializeCriticalSection': ambiguous call to overloaded function
note: could be 'void boost::container::dtl::InitializeCriticalSection(_RTL_CRITICAL_SECTION *)'
C:/WinSdk/Include/10.0.17763.0/um\synchapi.h(123): note: or 'void InitializeCriticalSection(LPCRITICAL_SECTION)' [found using argument-dependent lookup]
note: while trying to match the argument list '(_RTL_CRITICAL_SECTION *)'

error C2668: 'boost::container::dtl::EnterCriticalSection': ambiguous call to overloaded function
note: could be 'void boost::container::dtl::EnterCriticalSection(_RTL_CRITICAL_SECTION *)'
C:/WinSdk/Include/10.0.17763.0/um\synchapi.h(133): note: or 'void EnterCriticalSection(LPCRITICAL_SECTION)' [found using argument-dependent lookup]
note: while trying to match the argument list '(_RTL_CRITICAL_SECTION *)'

error C2668: 'boost::container::dtl::LeaveCriticalSection': ambiguous call to overloaded function
note: could be 'void boost::container::dtl::LeaveCriticalSection(_RTL_CRITICAL_SECTION *)'
C:/WinSdk/Include/10.0.17763.0/um\synchapi.h(141): note: or 'void LeaveCriticalSection(LPCRITICAL_SECTION)' [found using argument-dependent lookup]
note: while trying to match the argument list '(_RTL_CRITICAL_SECTION *)'

error C2668: 'boost::container::dtl::DeleteCriticalSection': ambiguous call to overloaded function
note: could be 'void boost::container::dtl::DeleteCriticalSection(_RTL_CRITICAL_SECTION *)'
C:/WinSdk/Include/10.0.17763.0/um\synchapi.h(194): note: or 'void DeleteCriticalSection(LPCRITICAL_SECTION)' [found using argument-dependent lookup]
note: while trying to match the argument list '(_RTL_CRITICAL_SECTION *)'

@mrpi mrpi changed the title MSVC + boost 1.70 compilation error when windows.h is already included in detail/thread_mutex.hpp MSVC + boost 1.70 compilation error when windows.h is already included (detail/thread_mutex.hpp) Apr 17, 2019

@igaztanaga

This comment has been minimized.

Copy link
Member

commented Apr 24, 2019

Thanks for the report!

Lastique added a commit to Lastique/container that referenced this issue May 19, 2019
Fixes boostorg#116 ("MSVC + boost 1.70 compilation error when windows…
….h is already included (detail/thread_mutex.hpp)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.