Skip to content

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

@hyp

Description

@hyp

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;
  ^

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions