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

Zig is silently caching an old cimport.h with angle brackets, despite deleting .zig-cache. #23434

Closed
alsanie360 opened this issue Apr 2, 2025 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@alsanie360
Copy link

Zig Version

0.14.0

Steps to Reproduce and Observed Behavior

Environment:
• Zig version: 0.14.0
• Platform: macOS 15 (Apple Silicon M3)

Steps to Reproduce:
1. Create a header file in your project:
mylib/mylib.h
2. Add the header path in build.zig:
exe.addIncludePath(b.path("mylib"));
3. In your .zig file, use:
const c = @cImport({
@Cinclude("mylib.h");
});
4. Initially (by mistake), use:
@Cinclude(<mylib.h>);
5. Fix it by changing to quotes and deleting .zig-cache:
@Cinclude("mylib.h");

            rm -rf .zig-cache
            zig build

Observed Behavior:
• Zig continues to generate cimport.h with:
#include <mylib.h>

•	Even after correcting to @cInclude("mylib.h") and clearing .zig-cache
•	The build fails with:
            error: 'mylib.h' file not found

Expected Behavior

•	After correcting to @cInclude("mylib.h") and clearing .zig-cache, Zig should regenerate cimport.h using quotes, not angle brackets.
•	The build should succeed if the header is available in addIncludePath.
@alsanie360 alsanie360 added the bug Observed behavior contradicts documented or intended behavior label Apr 2, 2025
@mlugg
Copy link
Member

mlugg commented Apr 2, 2025

Working as intended, @cInclude always emits code using '#include <angle_brackets> rather than #cinclude "quoted". Your original code of @cInclude(<mylib.h>) is not valid Zig syntax, and will have emitted a compile error and not generated any C code at all.

Note that @cImport and friends are set to be deleted: #20630

@mlugg mlugg closed this as not planned Won't fix, can't repro, duplicate, stale Apr 2, 2025
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
Projects
None yet
Development

No branches or pull requests

2 participants