Skip to content

Commit c384809

Browse files
simonbyrnevtjnash
authored andcommitted
Document that cfunctions should not throw errors (JuliaLang#43100)
* Document that cfunctions should not throw errors This was not documented, see https://discourse.julialang.org/t/what-happens-when-you-throw-an-error-from-a-cfunction/71510?u=simonbyrne * Update doc/src/manual/calling-c-and-fortran-code.md Co-authored-by: Jameson Nash <[email protected]> Co-authored-by: Jameson Nash <[email protected]>
1 parent 6302046 commit c384809

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

doc/src/manual/calling-c-and-fortran-code.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ Julia function. The arguments to [`@cfunction`](@ref) are:
186186
function on 32-bit Windows, but can be used on WIN64 (where `stdcall` is unified with the
187187
C calling convention).
188188
189+
!!! note
190+
Callback functions exposed via `@cfunction` should not throw errors, as that will
191+
return control to the Julia runtime unexpectedly and may leave the program in an undefined state.
192+
189193
A classic example is the standard C library `qsort` function, declared as:
190194
191195
```c

0 commit comments

Comments
 (0)