Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated C headers contain invalid types. #3924

Open
nmichaels opened this issue Dec 16, 2019 · 1 comment
Open

Generated C headers contain invalid types. #3924

nmichaels opened this issue Dec 16, 2019 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior emit-h This issue is related to generating .h files for C interop
Milestone

Comments

@nmichaels
Copy link
Contributor

Starting with this code:

const std = @import("std");

const Thingamajig = @OpaqueType();
const Thingamajigger = ThingHolder(i8, 8);
export fn do_thing(bar: *Thingamajigger) void {
    std.debug.warn("thing 0: {}\n", .{bar.*.things[0]});
}

pub fn thingify(foo: *Thingamajig) void {
    const bar = @ptrCast(*Thingamajigger, foo);
    do_thing(bar);
}

pub fn ThingHolder(comptime T: type, comptime count: usize) type {
    return struct {
        things: [count]T,
    };
}

Then running zig build-lib main.zig, I find this line in the generated header:

struct ThingHolder(i8,8);

If I change pub to export for do_thing, I also get this line:

void do_thing(struct ThingHolder(i8,8) * bar);

I expect it to either generate valid C tokens or abort with an error message.

@andrewrk andrewrk added this to the 0.7.0 milestone Dec 20, 2019
@andrewrk
Copy link
Member

I'd like to invest in self-hosted before investing in improving .h file generation; this way the work on this feature can be done once rather than twice.

@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 17, 2020
@SpexGuy SpexGuy added bug Observed behavior contradicts documented or intended behavior emit-h This issue is related to generating .h files for C interop labels Mar 21, 2021
@andrewrk andrewrk modified the milestones: 0.8.0, 0.8.1 Jun 4, 2021
@andrewrk andrewrk modified the milestones: 0.8.1, 0.9.1 Sep 1, 2021
@andrewrk andrewrk modified the milestones: 0.9.1, 0.9.0, 0.10.0 Nov 20, 2021
@andrewrk andrewrk modified the milestones: 0.10.0, 0.11.0 Apr 16, 2022
@Vexu Vexu modified the milestones: 0.11.0, 0.12.0 Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior emit-h This issue is related to generating .h files for C interop
Projects
None yet
Development

No branches or pull requests

4 participants