Skip to content

Commit cd13dad

Browse files
Add note for _weakLinked.
1 parent 9ef9efd commit cd13dad

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,18 @@ dynamic replacement of functions with an opaque return type.
590590

591591
## `@_weakLinked`
592592

593+
Allows a declaration to be weakly-referenced, i.e., any references emitted by
594+
client modules to the declaration's symbol will have weak linkage. This means
595+
that client code will compile without the guarantee that the symbol will be
596+
available at runtime. This requires a dynamic safety check (such as using
597+
`dlsym (3)`); otherwise, accessing the symbol when it is unavailable leads
598+
to a runtime crash.
599+
600+
This is an unsafe alternative to using `@available`, which is statically checked.
601+
If the availability of a library symbol is newer than the deployment target of
602+
the client, the symbol will be weakly linked, but checking for `@available` and
603+
`#(un)available` ensures that a symbol is not accessed when it is unavailable.
604+
593605
## `@_unsafeMainActor`, `@_unsafeSendable`
594606

595607
Marks a parameter's (function) type as `@MainActor` (`@Sendable`) in Swift 6 and

0 commit comments

Comments
 (0)