Skip to content

Commit 2e159b0

Browse files
authored
Merge pull request #273 from JohnTitor/mention-extern-types
Mention "extern types" on the opaque structs section
2 parents b44af9d + 538345a commit 2e159b0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/ffi.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,9 +703,8 @@ for more information.
703703

704704
## Representing opaque structs
705705

706-
Sometimes, a C library wants to provide a pointer to something, but not let you
707-
know the internal details of the thing it wants. The simplest way is to use a
708-
`void *` argument:
706+
Sometimes, a C library wants to provide a pointer to something, but not let you know the internal details of the thing it wants.
707+
A stable and simple way is to use a `void *` argument:
709708

710709
```c
711710
void foo(void *arg);
@@ -774,3 +773,9 @@ Notice that it is a really bad idea to use an empty enum as FFI type.
774773
The compiler relies on empty enums being uninhabited, so handling values of type
775774
`&Empty` is a huge footgun and can lead to buggy program behavior (by triggering
776775
undefined behavior).
776+
777+
> **NOTE:** The simplest way would use "extern types".
778+
But it's currently (as of June 2021) unstable and has some unresolved questions, see the [RFC page][extern-type-rfc] and the [tracking issue][extern-type-issue] for more details.
779+
780+
[extern-type-issue]: https://github.com/rust-lang/rust/issues/43467
781+
[extern-type-rfc]: https://rust-lang.github.io/rfcs/1861-extern-types.html

0 commit comments

Comments
 (0)