asio icon indicating copy to clipboard operation
asio copied to clipboard

Construction of `steady_timer` throws `std::system_error`

Open KeqingMoe opened this issue 5 months ago • 0 comments

Environment:

  • OS: Windows 11 23H2
  • Toolchains:
    • Compiler: llvm-mingw (clang version: 20.1.8, target: x86_64-w64-windows-gnu, thread model: posix)
    • xmake: v3.0.1+dev.861ca5b20
  • Asio version: 1.34.2
  • Architecture: x64

Code:

#include <asio.hpp>
auto main() -> int
{
    auto ctx = asio::io_context{};
    auto timer = asio::steady_timer{ctx};
}

xmake.lua:

add_rules("mode.debug", "mode.release")
add_rules("plugin.compile_commands.autoupdate")

set_toolchains("llvm")
set_plat("mingw")
set_runtimes("c++_static")
set_languages("c++26")

set_warnings("all")
set_warnings("error")

if is_mode("debug") then
    add_cxxflags("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG")
end

add_requires("asio")

if is_plat("windows") then
    add_links("wsock32")
end

add_defines("_WIN32_WINNT=0x0601")

target("test")
    add_packages("asio")
    add_files("test.cpp")

Output:

libc++abi: terminating due to uncaught exception of type std::__1::system_error: thread: 参考的对象类型不支持尝试的操作。
error: execv(C:\Users\**********\build\mingw\x64\release\test.exe ) failed(-1073740791)

KeqingMoe avatar Jul 12 '25 08:07 KeqingMoe