Skip to content

regression: translate-c output struct depends on itself (false positive) #17227

@acgaudette

Description

@acgaudette

Zig Version

0.12.0-dev.464+a63a1c5cb

Steps to Reproduce and Observed Behavior

a project depending on several C headers previously compiled, but now throws an error inside a file generated by translate-c.

the header in question is generated by cimgui (including as a keyword in case anyone else has this specific problem) and should probably be considered 'valid' as it has many dependents in the wild.

I've pared the error down to a minimal example:

const c = @cImport(@cInclude("include.h"));

pub fn main() void
{
        var b: c.B = undefined;
        _ = b;
}

'include.h'

struct A
{
        struct C* c;
};

struct B
{
        struct A* a;
};

struct C
{
        struct B b;
};
error: struct '.cimport.struct_B' depends on itself
pub const struct_B = extern struct {
                     ~~~~~~~^~~~~~

the error is pretty easy to reproduce with the actual cimgui header, so I can include that if necessary.

this occurs in 0.12.0-dev.464+a63a1c5cb but not 0.12.0-dev.415+5af5d87ad, which means this occurred somewhere inside the big batch of commits in the last couple days.

perhaps
f91ff9a @jayschwa
or changes by @andrewrk, @jacobly0

Expected Behavior

compilation succeeds

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviortranslate-cC to Zig source translation feature (@cImport)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions