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

fail to run zig build test on example from Export functions, variables, and types for C code to depend on #8888

Open
swuecho opened this issue May 24, 2021 · 4 comments
Labels
bug Observed behavior contradicts documented or intended behavior emit-h This issue is related to generating .h files for C interop
Milestone

Comments

@swuecho
Copy link

swuecho commented May 24, 2021

https://ziglang.org/learn/overview/#integration-with-c-libraries-without-ffibindings

zig build test
./build.zig:8:48: error: array literal requires address-of operator to coerce to slice type '[]const []const u8'
exe.addCSourceFile("test.c", [_][]const u8 {"-std=c99"});

seems slice is expected after make the following change.

    const cstr = [_][]const u8{"-std=c99"} ;
    exe.addCSourceFile("test.c", cstr[0..1]);

another problem,

 zig build test
error(compilation): clang failed with stderr: /home/xxx/zig/mathtest_c/test.c:1:10: fatal error: 'mathtest.h' file not found
@swuecho
Copy link
Author

swuecho commented May 24, 2021

➜ zsh git:(master) ✗ zig version
0.8.0-dev.2629+1c636e256
➜ zsh git:(master) ✗ uname -a
Linux 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

@g-w1
Copy link
Contributor

g-w1 commented May 24, 2021

I believe this is caused by emit-h not being enabled in stage1 builds.

@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label May 24, 2021
@andrewrk andrewrk added this to the 0.8.0 milestone May 24, 2021
@andrewrk andrewrk modified the milestones: 0.8.0, 0.8.1 Jun 4, 2021
@McSinyx
Copy link
Contributor

McSinyx commented Aug 18, 2021

seems slice is expected after make the following change.

From the docs, it is

exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});

I believe this is caused by emit-h not being enabled in stage1 builds.

In that case, should this be marked as a duplicate of GH-6753?

@andrewrk andrewrk modified the milestones: 0.8.1, 0.9.1 Aug 31, 2021
@andrewrk andrewrk modified the milestones: 0.9.1, 0.9.0, 0.10.0 Nov 20, 2021
@hhstore
Copy link

hhstore commented Aug 3, 2022

 zig version
0.10.0-dev.2617+47c4d4450

errors:

zig build-lib  src/zigmath.zig -femit-h

warning(compilation): -femit-h is not available in the stage1 backend; no .h file will be produced

@andrewrk andrewrk modified the milestones: 0.10.0, 0.11.0 Sep 14, 2022
@andrewrk andrewrk modified the milestones: 0.11.0, 0.12.0 Jun 19, 2023
@andrewrk andrewrk added the emit-h This issue is related to generating .h files for C interop label Aug 14, 2024
@andrewrk andrewrk modified the milestones: 0.14.0, 0.16.0 Aug 14, 2024
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

5 participants