mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-11-27 18:53:42 +03:00
Add missing bit of example in ffi docs
This commit is contained in:
parent
21a7b46ca1
commit
526c5f7d3a
@ -176,11 +176,13 @@ Callbacks
|
||||
|
||||
It is often useful in C for a function to take a *callback*, that is a function
|
||||
which is called after doing some work. For example, we can write a function
|
||||
which takes callback that takes a ``char*`` and an ``int`` and returns a
|
||||
which takes a callback that takes a ``char*`` and an ``int`` and returns a
|
||||
``char*``, in C, as follows (added to ``smallc.c`` above):
|
||||
|
||||
::
|
||||
|
||||
typedef char*(*StringFn)(char*, int);
|
||||
|
||||
char* applyFn(char* x, int y, StringFn f) {
|
||||
printf("Applying callback to %s %d\n", x, y);
|
||||
return f(x, y);
|
||||
|
Loading…
Reference in New Issue
Block a user