You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/topics/native/mapping-function-pointers-from-c.md
+6-7Lines changed: 6 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,16 @@
1
1
[//]: #(title: Mapping function pointers from C – tutorial)
2
2
3
3
<tldr>
4
-
<p>This is the third part of the <strong>Mapping Kotlin and C</strong> tutorial series.</p>
4
+
<p>This is the third part of the <strong>Mapping Kotlin and C</strong> tutorial series. Before proceeding, make sure you've completed the previous steps.</p>
5
5
<p><img src="icon-1-done.svg" width="20" alt="First step"/> <a href="mapping-primitive-data-types-from-c.md">Mapping primitive data types from C</a><br/>
6
6
<img src="icon-2-done.svg" width="20" alt="Second step"/> <a href="mapping-struct-union-types-from-c.md">Mapping struct and union types from C</a><br/>
7
7
<img src="icon-3.svg" width="20" alt="Third step"/> <strong>Mapping function pointers</strong><br/>
8
8
<img src="icon-4-todo.svg" width="20" alt="Fourth step"/> <a href="mapping-strings-from-c.md">Mapping strings from C</a><br/>
9
9
</p>
10
10
</tldr>
11
11
12
-
> The C libraries import is [Experimental](components-stability.md#stability-levels-explained).
13
-
> All Kotlin declarations generated by the `cinterop` tool from C libraries
14
-
> should have the `@ExperimentalForeignApi` annotation.
12
+
> The C libraries import is [Experimental](components-stability.md#stability-levels-explained). All Kotlin declarations
13
+
> generated by the cinterop tool from C libraries should have the `@ExperimentalForeignApi` annotation.
15
14
>
16
15
> Native platform libraries shipped with Kotlin/Native (like Foundation, UIKit, and POSIX)
17
16
> require opt-in only for some APIs.
@@ -75,7 +74,7 @@ Let's see how C function pointers are mapped into Kotlin/Native and update your
75
74
}
76
75
```
77
76
78
-
2. Use the IntelliJ IDEA's [Go to declaration](https://www.jetbrains.com/help/rider/Navigation_and_Search__Go_to_Declaration.html)
77
+
2. Use IntelliJ IDEA's [Go to declaration](https://www.jetbrains.com/help/rider/Navigation_and_Search__Go_to_Declaration.html)
79
78
command (<shortcut>Cmd + B</shortcut>/<shortcut>Ctrl + B</shortcut>) to navigate to the following generated API
80
79
for C functions:
81
80
@@ -134,7 +133,7 @@ fun myFun2() {
134
133
135
134
Kotlin turns the function pointer return type into a nullable `CPointer<CFunction<>` object. You need to first explicitly
136
135
check for `null`, which is why the [Elvis operator](null-safety.md) is used in the code above.
137
-
The `cinterop` tool allows you to call a C function pointer as a regular Kotlin function call: `functionFromC(42)`.
136
+
The cinterop tool allows you to call a C function pointer as a regular Kotlin function call: `functionFromC(42)`.
138
137
139
138
## Update Kotlin code
140
139
@@ -159,7 +158,7 @@ fun main() {
159
158
}
160
159
```
161
160
162
-
To verify that everything works as expected, run the `runDebugExecutableNative` Gradle task [in IDE](native-get-started.md#build-and-run-the-application)
161
+
To verify that everything works as expected, run the `runDebugExecutableNative` Gradle task [in your IDE](native-get-started.md#build-and-run-the-application)
0 commit comments