Skip to content

Commit

Permalink
Document that cfunctions should not throw errors (JuliaLang#43100)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
simonbyrne and vtjnash committed Nov 17, 2021
1 parent df2abc6 commit 0722f3c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/src/manual/calling-c-and-fortran-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ Julia function. The arguments to [`@cfunction`](@ref) are:
function on 32-bit Windows, but can be used on WIN64 (where `stdcall` is unified with the
C calling convention).
!!! note
Callback functions exposed via `@cfunction` should not throw errors, as that will
return control to the Julia runtime unexpectedly and may leave the program in an undefined state.
A classic example is the standard C library `qsort` function, declared as:
```c
Expand Down

0 comments on commit 0722f3c

Please sign in to comment.