[libcxx-commits] [libcxx] [libc++] Add std::stacktrace (P0881R7) (PR #136528)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 11 15:15:15 PST 2026


================
@@ -0,0 +1,295 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(_WIN32)
+
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>
+//
+#  include <dbghelp.h>
+#  include <psapi.h>
+//
+#  include <__stacktrace/basic_stacktrace.h>
+#  include <__stacktrace/stacktrace_entry.h>
+#  include <cstring>
+#  include <mutex>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+namespace __stacktrace {
+
+namespace {
+
+namespace __dll {
+
+template <typename F>
+bool get_func(HMODULE module, F** func, char const* name) {
+  return ((*func = reinterpret_cast<F*>(reinterpret_cast<void*>(GetProcAddress(module, name)))) != nullptr);
+}
+
+// clang-format off
+bool(WINAPI* EnumProcessModules)(HANDLE, HMODULE*, DWORD, DWORD*);
----------------
R-Goc wrote:

These are not defined as bool, but BOOL. A BOOL is not a bool, but an int under the hood. 

https://github.com/llvm/llvm-project/pull/136528


More information about the libcxx-commits mailing list