Skip to content

Use the prefix swift_testing_ for future exported symbols. #1238

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

Merged
merged 1 commit into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Documentation/StyleGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,26 @@ to the code called by the initialization expression causing the inferred type of
its property to change unknowingly, which could break clients. Properties with
lower access levels may have an inferred type.

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

```c
SWT_EXTERN bool swt_isDebugModeEnabled(void);

SWT_EXTERN void swt_setDebugModeEnabled(bool isEnabled);
```

> [!NOTE]
> If a symbol is meant to be **publicly visible** and can be called by modules
> other than Swift Testing, use the prefix `swift_testing_` instead of `swt_`
> for consistency with the Swift standard library:
>
> ```c
> SWT_EXTERN void swift_testing_debugIfNeeded(void);
> ```

C and C++ types should be given the prefix `SWT` and should otherwise be named
using the same UpperCamelCase naming rules as in Swift. For example:

Expand Down
4 changes: 4 additions & 0 deletions Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ extension ABI.v0 {
///
/// - Returns: The value of ``ABI/v0/entryPoint-swift.type.property`` cast to an
/// untyped pointer.
///
/// - Note: This function's name is prefixed with `swt_` instead of
/// `swift_testing_` for binary compatibility reasons. Future ABI entry point
/// functions should use the `swift_testing_` prefix instead.
@_cdecl("swt_abiv0_getEntryPoint")
@usableFromInline func abiv0_getEntryPoint() -> UnsafeRawPointer {
unsafeBitCast(ABI.v0.entryPoint, to: UnsafeRawPointer.self)
Expand Down