Skip to content

Commit 5fecefc

Browse files
authored
Use the prefix swift_testing_ for future exported symbols. (swiftlang#1238)
This PR updates our naming guidelines for exported/public C symbols. Right now, the only functions that would qualify are `swt_abiv0_getEntryPoint()` and `swt_copyABIEntryPoint_v0()` and their names must be preserved for binary compatibility with Xcode 16 through Xcode 26 anyway. Thus, this change is a documentation change only. Resolves swiftlang#1064. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [ ] If public symbols are renamed or modified, DocC references should be updated.
1 parent 0f809e4 commit 5fecefc

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

Documentation/StyleGuide.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,26 @@ to the code called by the initialization expression causing the inferred type of
7171
its property to change unknowingly, which could break clients. Properties with
7272
lower access levels may have an inferred type.
7373

74-
Exported C and C++ symbols that are exported should be given the prefix `swt_`
75-
and should otherwise be named using the same lowerCamelCase naming rules as in
76-
Swift. Use the `SWT_EXTERN` macro to ensure that symbols are consistently
77-
visible in C, C++, and Swift. For example:
74+
C and C++ symbols that are used by the testing library should be given the
75+
prefix `swt_` and should otherwise be named using the same lowerCamelCase naming
76+
rules as in Swift. Use the `SWT_EXTERN` macro to ensure that symbols are
77+
consistently visible in C, C++, and Swift. For example:
7878

7979
```c
8080
SWT_EXTERN bool swt_isDebugModeEnabled(void);
8181

8282
SWT_EXTERN void swt_setDebugModeEnabled(bool isEnabled);
8383
```
8484
85+
> [!NOTE]
86+
> If a symbol is meant to be **publicly visible** and can be called by modules
87+
> other than Swift Testing, use the prefix `swift_testing_` instead of `swt_`
88+
> for consistency with the Swift standard library:
89+
>
90+
> ```c
91+
> SWT_EXTERN void swift_testing_debugIfNeeded(void);
92+
> ```
93+
8594
C and C++ types should be given the prefix `SWT` and should otherwise be named
8695
using the same UpperCamelCase naming rules as in Swift. For example:
8796

Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ extension ABI.v0 {
6767
///
6868
/// - Returns: The value of ``ABI/v0/entryPoint-swift.type.property`` cast to an
6969
/// untyped pointer.
70+
///
71+
/// - Note: This function's name is prefixed with `swt_` instead of
72+
/// `swift_testing_` for binary compatibility reasons. Future ABI entry point
73+
/// functions should use the `swift_testing_` prefix instead.
7074
@_cdecl("swt_abiv0_getEntryPoint")
7175
@usableFromInline func abiv0_getEntryPoint() -> UnsafeRawPointer {
7276
unsafeBitCast(ABI.v0.entryPoint, to: UnsafeRawPointer.self)

0 commit comments

Comments
 (0)