Skip to content

ABI export: export Nothing/Cvoid as null#122

Open
fredrikekre wants to merge 2 commits into
mainfrom
fe/void
Open

ABI export: export Nothing/Cvoid as null#122
fredrikekre wants to merge 2 commits into
mainfrom
fe/void

Conversation

@fredrikekre

@fredrikekre fredrikekre commented Mar 18, 2026

Copy link
Copy Markdown
Member

In the context of C-entrypoints Nothing should not really be treated as any other struct but as Cvoid. This patch changes the ABI export of Nothing from struct to primitive.

Perhaps it should be it's own kind? The change here made the change for JuliaLibWrapping trivial (JuliaInterop/JuliaLibWrapping.jl#6) but perhaps we can pattern match for a size-0 struct called Nothing over there as an alternative...

fredrikekre added a commit to fredrikekre/JuliaLibWrapping.jl that referenced this pull request Mar 18, 2026
This patch maps Nothing to void in the C export,
see JuliaLang/JuliaC.jl#122.
@gbaraldi

Copy link
Copy Markdown
Member

I'm not sure if Julia expects a pure nothing argument to disappear or to become an equivalent to an Any. returning nothing is the same as void return, but not sure about argument.
CC @topolarity

@topolarity

Copy link
Copy Markdown
Member

Thanks!

We expect Cvoid in the return_type or the pointee_type I believe - I would probably prefer encoding this as null (i.e. no return / pointee type specified)

This patch changes the export of `Nothing`/`Cvoid` to JSON `null`.
Methods with `Cvoid` return type will be exported with `"returns": null`
and `Ptr{Cvoid}`, as return type or argument type, will be exported with
`{"kind": "pointer", pointee_type_id": null}`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fredrikekre

Copy link
Copy Markdown
Member Author

Updated the PR -- is this what you meant?

Comment thread src/abi_export.jl Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fredrikekre fredrikekre changed the title ABI export: export Nothing as a primitive type ABI export: export Nothing/Cvoid as null Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants