Skip to content

c_import: should C function-pointer fields import as nullable? (D101 zero-validity) #2215

Closed

Description

@ehartford

D101 makes T.zeroed() available only on zero-valid C records. c_import maps a C function-pointer field to a non-null extern "C" fn (zlib z_stream.zalloc, stdlib sigevent.sigev_notify_function), so those records have no zeroed(), and an in-place facade over real zlib's z_stream would need a preinit. In C such a field is routinely NULL (zlib's Z_NULL zalloc means "use the default"), so non-null is arguably the wrong model. Importing them as nullable would make these records zero-valid. This is a C-interop mapping question for Eric.

Activity

  1. ehartford commented on Oct 6, 2026

    @ehartford
    ContributorAuthor

    Ruled D102 and implemented by #2218 (73c7cf8): c_import maps function pointers by direction — field, element, pointee, return and global are Option; typedef and a c_import prototype's parameter stay non-null; a facade widens a parameter with nullable param N; a migrated definition's parameter keeps C's nullability. zlib's z_stream and stdlib's sigevent are zero-valid under D101 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions