Skip to content

Commit ba2c8cc

Browse files
[c-interop][docs] Add @_extern(c) attribute explanation
1 parent bdbb7dc commit ba2c8cc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,20 @@ through WebAssembly's import interface.
449449

450450
It's the equivalent of clang's `__attribute__((import_module("module"), import_name("field")))`.
451451

452+
### `@_extern(c, [, <"cName">])`
453+
454+
Indicates that a particular declaration should refer to a
455+
C declaration with the given name. If the optional "cName"
456+
string is not specified, the mangled Swift name will be used.
457+
458+
Similar to `@_cdecl`, but this attribute is used to reference
459+
C declarations from Swift, while `@_cdecl` is used to be referenced
460+
from C.
461+
462+
Also similar to `@_silgen_name`, but a function declared with
463+
`@_extern(c)` is assumed to use the C ABI, while `@_silgen_name`
464+
assumes the Swift ABI.
465+
452466
## `@_fixed_layout`
453467

454468
Same as `@frozen` but also works for classes.

0 commit comments

Comments
 (0)