Skip to content

Cant compile structs with timespec from musl libc #6702

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

Closed
maringuu opened this issue Oct 16, 2020 · 2 comments
Closed

Cant compile structs with timespec from musl libc #6702

maringuu opened this issue Oct 16, 2020 · 2 comments

Comments

@maringuu
Copy link

Hello,
I'm not sure where to report this but I think the error is in zig and not in musl.
I currently can't test with glibc but it worked a week ago before I switched to musl.

I can't compile (with the 0.6 and master versions of zig) the following:

main.zig

const c = @cImport({
    @cInclude("crash.h");
});

pub fn main() void {
    const foobar: c.foo = undefined;
}

crash.h

#ifndef _CRASH_H
#define _CRASH_H

#include <time.h>

struct foo {
	struct timespec bar;
};

#endif

When compiling with zig build-exe -lc -I. main.zig I get the following error messages:

zig-cache/o/1QBKyqQD7kLHJlhoCNMXT5wbPCc96MtwERrm4GmtTO75FIB9OM9P-TaGnN0SK1St/cimport.zig:63:5: error: opaque types have unknown size and therefore cannot be directly embedded in structs
    bar: struct_timespec,
    ^
./main.zig:6:27: note: referenced here
    const foobar: c.foo = undefined;

The c equivalent of this code compiles fine
main.c

#include "crash.h"

int main() {
    struct foo foo;
}
@tadeokondrak
Copy link
Contributor

This is #1499.

@Vexu Vexu closed this as completed Oct 16, 2020
@maringuu
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants