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 includes that aren't needed #4272

Closed
gdoenlen opened this issue Jan 23, 2020 · 2 comments · Fixed by #4278
Closed

Generated C headers contain includes that aren't needed #4272

gdoenlen opened this issue Jan 23, 2020 · 2 comments · Fixed by #4278

Comments

@gdoenlen
Copy link

Hi I'm compiling to freestanding and my generated C headers end up including things from std.

I only export the void main function and the other imports never import anything from the standard.
compile flags:

zig build-obj zworld.zig -target i386-freestanding-elfv1 -fno-PIC -I .

zig file:

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

export fn main() void {
    c.printf(2, "hello world");
    c.exit();
}

generated header:

#ifndef ZWORLD_H
#define ZWORLD_H

#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

void main(void);

#ifdef __cplusplus
} // extern "C"
#endif


#endif // ZWORLD_H

@tadeokondrak
Copy link
Contributor

This is a bug, but both stdint.h and stdbool.h are present in even freestanding C implementations.

@gdoenlen
Copy link
Author

Hmm ok I guess you need stdbool and int for compatibility with zig primitives? Makes sense thanks!

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

Successfully merging a pull request may close this issue.

2 participants