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

[windows] including only wtypes in sentry.h makes Swift fail to import sentry.h #934

Closed
1 task done
hyp opened this issue Jan 4, 2024 · 1 comment · Fixed by #935
Closed
1 task done

[windows] including only wtypes in sentry.h makes Swift fail to import sentry.h #934

hyp opened this issue Jan 4, 2024 · 1 comment · Fixed by #935

Comments

@hyp
Copy link
Contributor

hyp commented Jan 4, 2024

Description

https://github.com/thebrowsercompany/swift-sentry is a Swift wrapper for the native SDK for Sentry. It uses Swift's embedded clang to import sentry.h, by importing it as a Clang module. Clang modules rely on modularized headers, i.e. the header must be self contained, and it must import all header dependencies. Unfortunately sentry.h's import wtypes is problematic for two reasons:

  • it's incomplete, it uses APIs from other headers like winnt.h
  • the wtypes header is not modularized as a standalone module in the Windows SDK.

This causes a Swift build error with Swift-5.10 or Swift main snapshot. The error is shown below.

When does the problem happen

  • During build

Environment

  • OS: Windows 11, 64-bit
  • Compiler: Swift 5.10 snapshot
  • SDK: Windows 10 SDK (10.0.20348.0)

Steps To Reproduce

Build swift-sentry.

Log output

......\build\debug\_deps\swiftsentry-src\Sources\sentry\include/SentryApp.h:6:10: note: in file included from ......\build\debug\_deps\swiftsentry-src\Sources\sentry\include/SentryApp.h:6:
#include <sentry.h>
         ^
......\build\debug\NugetPackages\io.sentry.sentry-native.crashpad.windows.amd64.0.0.0-ede193b\include\sentry.h:93:14: note: in file included from ......\build\debug\NugetPackages\io.sentry.sentry-native.crashpad.windows.amd64.0.0.0-ede193b\include\sentry.h:93:
#    include <wtypes.h>
             ^
C:\Program Files (x86)\Windows Kits\10\\include\10.0.20348.0\\shared\wtypes.h:323:15: error: missing '#include <windef.h>'; 'RECTL' must be declared before it is used
typedef const RECTL *LPCRECTL;
              ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\shared\windef.h:170:3: note: declaration here is not visible
} RECTL, *PRECTL, *LPRECTL;
  ^
@hyp
Copy link
Contributor Author

hyp commented Jan 4, 2024

This can be resolved by including #windows.h instead.

hyp added a commit to hyp/sentry-native that referenced this issue Jan 4, 2024
This makes it possible to use this header in Swift

Fixes getsentry#934
@getsantry getsantry bot removed the status in GitHub Issues with 👀 2 Jan 8, 2024
hyp added a commit to hyp/sentry-native that referenced this issue Jan 8, 2024
This makes it possible to use this header in Swift

Fixes getsentry#934
@github-project-automation github-project-automation bot moved this from Needs Discussion to Done in Mobile & Cross Platform SDK Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants