Skip to content

Commit

Permalink
Explain how to pass NULL pointer via FFI
Browse files Browse the repository at this point in the history
  • Loading branch information
jpellegrini committed Jul 31, 2024
1 parent 5bdb4d7 commit f6d883c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions doc/refman/ffi.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ the FFI better!):
=> "ring"
```
In order to pass a `NULL` pointer to an external C function, the
`#void` Scheme value can be used.
As an example, the second argument to the `strtol` function can be
`NULL`:
```scheme
(define-external strtol(:string :pointer :int)
:return-type :long)
```
```scheme
(strtol "1001" #void 10) => 1001
(strtol "1001" #void 2) => 9
```
Functions on C pointers are described in the next section.
### C pointers
Expand All @@ -178,5 +194,3 @@ errors, crashes...
{{insertdoc 'cpointer->string}}
{{insertdoc 'allocate-bytes}}
{{insertdoc 'free-bytes}}

0 comments on commit f6d883c

Please sign in to comment.