Skip to content

explain @cfunction in Embedding Julia manual #38932

@stevengj

Description

@stevengj

For people wanting to call Julia from C/C++, I would generally recommend doing all of the type conversions on the Julia side, and then use jl_unbox_voidpointer(jl_eval_string("@cfunction(....)")) to compile and extract a C function pointer that you can then call normally. This is vastly easier than constructing/unboxing Julia types from the C/C++ side.

It would be good to document this in the Embedding Julia manual, which currently doesn't mention @cfunction at all.

(For example, this came up on stackoverflow in a question about calling the Julia SpecialFunctions.polygamma function from C++.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentationembeddingEmbedding Julia using the C API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions