Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Oct 9, 2025

On Windows, GUID is a currency type and (along with its various typedefs) is used pervasively Windows offers IsEqualGUID() and UuidHash() for comparing and hashing them, respectively, but IsEqualGUID() is a macro in C mode and UuidHash() only provides a 16-bit hash. We should provide conformance to these protocols in the WinSDK overlay to provide equivalent functionality in Swift.

@grynspan grynspan added this to the Swift 6.3 milestone Oct 9, 2025
@grynspan grynspan self-assigned this Oct 9, 2025
@grynspan grynspan requested a review from compnerd as a code owner October 9, 2025 16:47
@grynspan grynspan added Windows Platform: Windows SDKOverlay labels Oct 9, 2025
On Windows, `GUID` is a currency type and (along with its various typedefs) is
used pervasively Windows offers `IsEqualGUID()` and `UuidHash()` for comparing
and hashing them, respectively, but `IsEqualGUID()` is a macro in C mode and
`UuidHash()` only provides a 16-bit hash. We should provide conformance to these
protocols in the WinSDK overlay to provide equivalent functionality in Swift.
@grynspan grynspan force-pushed the jgrynspan/windows-GUID-hashable branch from 9fd42ec to baf4506 Compare October 9, 2025 16:55
@grynspan grynspan requested a review from a team as a code owner October 9, 2025 16:55
@grynspan grynspan requested a review from compnerd October 9, 2025 17:04
@grynspan
Copy link
Contributor Author

grynspan commented Oct 9, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Oct 9, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Oct 9, 2025

@swift-ci test macOS

@grynspan
Copy link
Contributor Author

grynspan commented Oct 9, 2025

@swift-ci test Windows

@grynspan
Copy link
Contributor Author

grynspan commented Oct 9, 2025

@swift-ci smoke test

@grynspan grynspan linked an issue Oct 9, 2025 that may be closed by this pull request
@grynspan
Copy link
Contributor Author

@swift-ci smoke test macOS

@grynspan grynspan merged commit 5846e8f into main Oct 10, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/windows-GUID-hashable branch October 10, 2025 12:34
dendiz pushed a commit to dendiz/swift that referenced this pull request Oct 21, 2025
On Windows, `GUID` is a currency type and (along with its various
typedefs) is used pervasively Windows offers `IsEqualGUID()` and
`UuidHash()` for comparing and hashing them, respectively, but
`IsEqualGUID()` is a macro in C mode and `UuidHash()` only provides a
16-bit hash. We should provide conformance to these protocols in the
WinSDK overlay to provide equivalent functionality in Swift.
speednoisemovement pushed a commit to speednoisemovement/swift that referenced this pull request Oct 29, 2025
On Windows, `GUID` is a currency type and (along with its various
typedefs) is used pervasively Windows offers `IsEqualGUID()` and
`UuidHash()` for comparing and hashing them, respectively, but
`IsEqualGUID()` is a macro in C mode and `UuidHash()` only provides a
16-bit hash. We should provide conformance to these protocols in the
WinSDK overlay to provide equivalent functionality in Swift.
grynspan added a commit that referenced this pull request Nov 11, 2025
In #84792 we have added
implementation to `Equatable` and `Hashable` there are two issues with
this.
1. Uses of type `GUID` would be emitted in the `swiftinterface` file as
`_GUIDDef._GUID` since it is an external type. but the type name in the
imported header file is `GUID` and not `_GUID`
2. When compiling using `-cxx-interoperability-mode=default`, there are
duplicate definition errors for `==` since the c++ header file defines
the same operator.

Proposed changes:
1. Add a type alias `typealias _GUID = GUID` to address the naming
mismatch in the generated interface file
2. Add conditional definitions of the equatable implementation to avoid
duplicate definitions.

---------

Co-authored-by: Jonathan Grynspan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SDKOverlay Windows Platform: Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants