-
-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Steps to reproduce:
- generate any sufficiently large struct (or used the attached example), for example using:
with open("test.h", "w") as header_file:
header_file.write("struct Test {\n")
for i in range(1001):
header_file.write(f" int field_{i};\n")
header_file.write("};\n\n")- use
zig translate-cor@cImportto include it.
Actual behavior:
for example building
const c = @cImport({
@cInclude("test.h");
});
pub fn main() void {
_ = c.Test;
}with
zig build-exe -I. test.zigwill always fail with:
/home/.../cimport.zig:1058:50: error: evaluation exceeded 1000 backwards branches
field_1000: c_int = @import("std").mem.zeroes(c_int),
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/home/.../cimport.zig:1058:50: note: use @setEvalBranchQuota() to raise the branch limit from 1000
referenced by:
struct_Test: /home/.../cimport.zig:57:32
Test: /home/.../cimport.zig:1522:18
6 reference(s) hidden; use '-freference-trace=8' to see all references
and since this error happens inside the generated struct definition, putting @setEvalBranchQuota() inside of the @cImport block will not have any effect. i also could not find any documentation or mechanism that would allow users to set a custom quota inside of the generated code.
Expected behavior:
translate-c should handle the quota increase or at least provide a mechanism and documentation that allows the users to do so.
Versions:
Zig 0.15.2 (installed through archlinux repos)
zig env
.{
.zig_exe = "/usr/bin/zig",
.lib_dir = "/usr/lib/zig",
.std_dir = "/usr/lib/zig/std",
.global_cache_dir = ".cache/zig",
.version = "0.15.2",
.target = "x86_64-linux.6.12.51...6.12.51-gnu.2.42",
.env = .{
.ZIG_GLOBAL_CACHE_DIR = null,
.ZIG_LOCAL_CACHE_DIR = null,
.ZIG_LIB_DIR = null,
.ZIG_LIBC = null,
.ZIG_BUILD_RUNNER = null,
.ZIG_VERBOSE_LINK = null,
.ZIG_VERBOSE_CC = null,
.ZIG_BTRFS_WORKAROUND = null,
.ZIG_DEBUG_CMD = null,
.CC = null,
.NO_COLOR = null,
.CLICOLOR_FORCE = null,
.XDG_CACHE_HOME = null,
.HOME = "/home/user",
},
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working