Skip to content

c_import: #include <pwd.h> on macOS fails to translate — uuid.h's UUID_NULL array constant renders as [16]u8 { 0, … }, which is not With syntax #1653

Closed

Description

@ehartford

Found while writing the D66 record-view fixtures (a struct passwd * from getpwuid as a borrowed record from a domain).

Repro (Darwin, stage1 or the installed compiler):

use c_import("#include <pwd.h>\n")
fn main:
    print("x")
error: expected declaration (fn, type, enum, let, use, extern)
 --> <c_import c_facade_record.h>:68:29
68 | let UUID_NULL: [16]u8 = [16]u8 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  |                             ^^

<pwd.h> pulls in <uuid/uuid.h>, whose static const uuid_t UUID_NULL = {0,…} (an array typedef unsigned char uuid_t[16]) is translated by ci_translate_var as [16]u8 { … } — a C-shaped initializer, not a With array literal ([0; 16] / [0, 0, …]). The translation fails loudly (good: no silent stub), but every header that includes uuid.h is unusable through c_import on macOS. The fixture moved to <locale.h> (localeconv → struct lconv *) instead.

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by #1705 (db89bc5): array constants translate to padded With array literals; #include <pwd.h> translates.

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