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

-DBOOST_COBALT_NO_PMR=1 breaks MSVC build #193

Closed
francoisk opened this issue Jul 22, 2024 · 0 comments
Closed

-DBOOST_COBALT_NO_PMR=1 breaks MSVC build #193

francoisk opened this issue Jul 22, 2024 · 0 comments

Comments

@francoisk
Copy link

The MSVC build fails with the following error if -DBOOST_COBALT_NO_PMR=1 is defined:

src\detail\util.cpp(23): error C2039: 'get_allocator': is not a member of 'boost::cobalt::this_thread'
src\detail\util.cpp(23): error C3861: 'get_allocator': identifier not found

As can be seen in the code snippets below, boost::cobalt::this_thread::get_allocator() is not declared if BOOST_COBALT_NO_PMR is defined, yet it is called unconditionally under MSVC.

#if !defined(BOOST_COBALT_NO_PMR)
BOOST_COBALT_DECL pmr::memory_resource* get_default_resource() noexcept;
BOOST_COBALT_DECL pmr::memory_resource* set_default_resource(pmr::memory_resource* r) noexcept;
BOOST_COBALT_DECL pmr::polymorphic_allocator<void> get_allocator();
#endif

#if defined(_MSC_VER)
// msvc doesn't correctly suspend for self-deletion, hence we must workaround here
#define BOOST_COBALT_NO_SELF_DELETE 1
#endif

#if BOOST_COBALT_NO_SELF_DELETE
void self_destroy(std::coroutine_handle<void> h, const cobalt::executor & exec) noexcept
{
asio::post(exec,
asio::bind_allocator(
this_thread::get_allocator(),
[del=unique_handle<void>(h.address())]() mutable
{
}));
}
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant