Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

cimport creates a @bitCast(@sizeOf()) #48

@Dario48true

Description

@Dario48true

Zig Version

0.14.1

Steps to Reproduce and Observed Behavior

  1. cimport any affected libraries (pipewire in my case)
  2. zig build
install
└─ install recorder
   └─ zig build-exe recorder Debug native 5 errors
/home/Dario48/Documents/programming_projects/stt/zig/.zig-cache/o/aa6354b09454ad6e2b9f25edc619deec/cimport.zig:8178:127: error: cannot @bitCast from 'comptime_int'
    return @as(?*anyopaque, @ptrFromInt(@as(usize, @intCast(@intFromPtr(pod))) +% @as(usize, @bitCast(@as(ptrdiff_t, @bitCast(@sizeOf(struct_spa_pod_array)))))));
                                                                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/Dario48/Documents/programming_projects/stt/zig/.zig-cache/o/aa6354b09454ad6e2b9f25edc619deec/cimport.zig:8390:130: error: cannot @bitCast from 'comptime_int'
    spa_pod_parser_init(parser, @as(?*const anyopaque, @ptrCast(pod)), @as(u32, @bitCast(@as(c_uint, @truncate(@as(u64, @bitCast(@sizeOf(struct_spa_pod))) +% @as(u64, @bitCast(@as(c_ulong, @as([*c]struct_spa_pod, @ptrCast(@volatileCast(@constCast(pod)))).*.size))))))));
                                                                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~
/home/Dario48/Documents/programming_projects/stt/zig/.zig-cache/o/aa6354b09454ad6e2b9f25edc619deec/cimport.zig:8437:143: error: cannot @bitCast from 'comptime_int'
    var size: u32 = @as(u32, @bitCast(@as(c_uint, @truncate(if (f != null) @as(u64, @bitCast(@as(c_ulong, f.*.offset))) +% (@as(u64, @bitCast(@sizeOf(struct_spa_pod))) +% @as(u64, @bitCast(@as(c_ulong, (&f.*.pod).*.size)))) else @as(u64, @bitCast(@as(c_ulong, parser.*.size)))))));
                                                                                                                                              ^~~~~~~~~~~~~~~~~~~~~~~
/home/Dario48/Documents/programming_projects/stt/zig/.zig-cache/o/aa6354b09454ad6e2b9f25edc619deec/cimport.zig:8464:143: error: cannot @bitCast from 'comptime_int'
    parser.*.state.offset = @as(u32, @bitCast(@as(c_uint, @truncate(@as(u64, @bitCast(@as(c_ulong, frame.*.offset))) +% ((((@as(u64, @bitCast(@sizeOf(struct_spa_pod))) +% @as(u64, @bitCast(@as(c_ulong, (&frame.*.pod).*.size)))) -% @as(u64, @bitCast(@as(c_long, @as(c_int, 1))))) | @as(@TypeOf(@as(u64, @bitCast(@sizeOf(struct_spa_pod))) +% @as(u64, @bitCast(@as(c_ulong, (&frame.*.pod).*.size)))), @bitCast(@as(c_long, @as(c_int, 8) - @as(c_int, 1))))) +% @as(u64, @bitCast(@as(c_long, @as(c_int, 1)))))))));
                                                                                                                                              ^~~~~~~~~~~~~~~~~~~~~~~
/home/Dario48/Documents/programming_projects/stt/zig/.zig-cache/o/aa6354b09454ad6e2b9f25edc619deec/cimport.zig:10112:78: error: integer and float literals passed to variadic function must be casted to a fixed-size number type
            _ = spa_pod_builder_add(builder, SPA_FORMAT_AUDIO_position, "a", @sizeOf(u32), SPA_TYPE_Id, info.*.channels, @as([*c]const u32, @ptrCast(@alignCast(&info.*.position[@as(usize, @intCast(0))]))), @as(c_int, 0));
                                                                             ^~~~~~~~~~~~
referenced by:
    main: src/main.zig:158:52
    main: /usr/lib/zig/std/start.zig:660:37
    3 reference(s) hidden; use '-freference-trace=5' to see all references
error: the following command failed with 5 compilation errors:
/usr/bin/zig build-exe -I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2 -D_REENTRANT -lpipewire-0.3 -ODebug -Mroot=/home/Dario48/Documents/programming_projects/stt/zig/src/main.zig -lc --cache-dir /home/Dario48/Documents/programming_projects/stt/zig/.zig-cache --global-cache-dir /home/Dario48/.cache/zig --name recorder --zig-lib-dir /usr/lib/zig/ --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed
install transitive failure
└─ install recorder transitive failure
   └─ zig build-exe recorder Debug native 5 errors
error: the following build command failed with exit code 1:
/home/Dario48/Documents/programming_projects/stt/zig/.zig-cache/o/7e07522844a5fe36046fa195104b5b4f/build /usr/bin/zig /usr/lib/zig /home/Dario48/Documents/programming_projects/stt/zig /home/Dario48/Documents/programming_projects/stt/zig/.zig-cache /home/Dario48/.cache/zig --seed 0xacac91ae -Z5b4302637a47f8d8

Expected Behavior

  1. cimport the library
  2. zig build
  3. no translation errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions