Skip to content

Fully isolate windows.h includes to source files#323

Merged
jeremy-rifkin merged 2 commits intojeremy-rifkin:mainfrom
ZeroMemes:isolate_windows_h
Mar 11, 2026
Merged

Fully isolate windows.h includes to source files#323
jeremy-rifkin merged 2 commits intojeremy-rifkin:mainfrom
ZeroMemes:isolate_windows_h

Conversation

@ZeroMemes
Copy link
Contributor

windows.h has a lot of transitive includes, and subsequently undesired macro definitions, that are not required for cpptrace's functionality. This change simply substitutes windows.h for excpt.h in from_current.hpp, fully isolating windows.h includes to cpptrace source files.

ctest passed locally on:

  • msvc 19.50
  • clang-cl 21.1.1

@ZeroMemes ZeroMemes marked this pull request as draft March 9, 2026 22:29
@ZeroMemes
Copy link
Contributor Author

Converting to draft until the failing CI checks can be resolved

@ZeroMemes ZeroMemes marked this pull request as ready for review March 9, 2026 22:49
Copy link
Owner

@jeremy-rifkin jeremy-rifkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@jeremy-rifkin
Copy link
Owner

https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-exception_pointers seems to indicate the definition comes from winnt.h but https://learn.microsoft.com/en-us/cpp/cpp/try-except-statement?view=msvc-170 indicates it comes from excpt.h, but if CI passes I'm happy to take that as a good sign excpt.h is correct

@jeremy-rifkin jeremy-rifkin merged commit 91b6b78 into jeremy-rifkin:main Mar 11, 2026
106 checks passed
@ZeroMemes
Copy link
Contributor Author

ZeroMemes commented Mar 11, 2026

Yeah, apologies for not elaborating at all on that.

The actual definition of EXCEPTION_POINTERS is indeed in winnt.h, but since all that's needed is a pointer type, a forward declaration is sufficient. Like you pointed out, excpt.h is documented to provide a macro definition of GetExceptionInformation(), and the documentation for that macro indicates that it evaluates to PEXCEPTION_POINTERS. Any compliant implementation of the Win32 API should be compatible with these changes.

@ZeroMemes ZeroMemes deleted the isolate_windows_h branch March 11, 2026 20:23
@jeremy-rifkin
Copy link
Owner

Perfect thanks! That gives me more confidence in the portability of this

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

Successfully merging this pull request may close these issues.

2 participants