Skip to content

Commit b62eafd

Browse files
committed
[windows] split out complex module from ucrt module, to allow new swift-foundation to import ucrt when C++ interoperability is enabled
Fixes swiftlang#75691
1 parent b55651f commit b62eafd

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

stdlib/public/Platform/ucrt.modulemap

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
module _complex [system] {
14+
header "complex.h"
15+
export *
16+
}
17+
1318
module ucrt [system] {
1419
module C {
15-
module complex {
16-
/* disallow the header in C++ mode as it forwards to `ccomplex`. */
17-
requires !cplusplus
18-
19-
header "complex.h"
20-
export *
21-
}
22-
2320
module ctype {
2421
header "ctype.h"
2522
export *

stdlib/public/Platform/ucrt.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import ucrt // Clang module
14+
// Extra clang module that's split out from ucrt:
15+
@_exported import _complex
1416

1517
@available(swift, deprecated: 3.0, message: "Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.")
1618
public let M_PI = Double.pi

test/Interop/Cxx/stdlib/foundation-and-std-module.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
// RUN: %target-swift-frontend %s -c -enable-experimental-cxx-interop -Xcc -std=c++17 -Xcc -fmodules-cache-path=%t
44
// RUN: %target-swift-frontend %s -c -enable-experimental-cxx-interop -Xcc -std=c++20 -Xcc -fmodules-cache-path=%t
55

6-
// RUN: find %t | %FileCheck %s
7-
86
// RUN: %empty-directory(%t)
97

108
// RUN: %target-swift-frontend %s -c -enable-experimental-cxx-interop -Xcc -std=c++17 -Xcc -fmodules-cache-path=%t -DADD_CXXSTDLIB
119
// RUN: %target-swift-frontend %s -c -enable-experimental-cxx-interop -Xcc -std=c++20 -Xcc -fmodules-cache-path=%t -DADD_CXXSTDLIB
1210

13-
// REQUIRES: OS=macosx || OS=linux-gnu
11+
// RUN: %{python} -c "import os, glob; print('\n'.join(glob.glob(os.path.join('%/t', '**', '*.pcm'), recursive=True)))" | %FileCheck %s
1412

1513
#if canImport(Foundation)
1614
import Foundation

test/stdlib/CRT.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-run-simple-swift %t
2+
// REQUIRES: executable_test
3+
// REQUIRES: OS=windows-msvc
4+
5+
// This file has CRT-specific C stdlib tests, that use
6+
// some APIs present only in CRT.
7+
8+
import StdlibUnittest
9+
import CRT
10+
11+
var CRTTests = TestSuite("CRT")
12+
13+
CRTTests.test("complex functions available in Swift") {
14+
let complexValue = _Cbuild(1.0, 2.0) // Construct a complex double using MSVC-specific API.
15+
let re = creal(complexValue)
16+
expectEqual(re, 1.0)
17+
}

0 commit comments

Comments
 (0)