-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Automatically add includes for cimports #7771
Comments
We could do the C thing and have two: @cInclude("foo.h"), // searches this directory first
@cInclude(<foo.h>), // searches only include directories (but please don't actually do this) In all seriousness though, the C compatibility features are there to match C. Since C's behavior for an include with quotes is to search the file's directory, and we use quotes (albeit for different reasons), I think we should do the same thing as C here and search the file's directory before searching include directories. |
@Sobeston I'm happy to re-open this if you clarify the proposal more. As it stands I don't really understand what it is suggesting. Can you include a full example with all files involved and the command line you expect to execute? |
Here's a complete example: // src/foo.c
#include "foo.h" // src/foo.h
#define FOO 1 // src/foo.zig
comptime {
_ = @cImport({
@cInclude("foo.h");
});
} The command |
Thanks! |
Solved by moving |
Currently if I have a folder that contains two files:
main.c
andmain.zig
, the following code insidemain.zig
does not work:This is because our way of including C files is modeled after how C does it (which makes total sense). However, this is a bad user experience and frankly unsatisfying.
What I propose here is automatically adding includes for cimports - one include at the directory of cimporting zig file.
The text was updated successfully, but these errors were encountered: