-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
make @cImport take comptime []u8 instead of an expression #9332
Comments
Would |
This makes the common-case simpler but also makes it uglier to use compile-time computations to control the C code that is compiled (you'd have to explicitly concat the strings yourself) - e.g. the second example here https://ziglang.org/documentation/0.8.0/#Import-from-C-Header-File I think I prefer the proposal in #2070 for achieving the goal of this proposal. I do agree that |
@nektro the proposed changes would not remove any functionality, they map directly to c preprocessor directives which could be used in the proposed |
@ehaas Yeah, you are right. It may actually be uglier in some cases. But it would still be possible. (And maybe we could add library functions to make it easier.) For me it still seems like much cleaner way of doing it, because we would use comptime language features instead of compiler magic.
@zigazeljko Full comptime expressions would be necessary to keep the example mentioned by @ehaas possible. |
Duplicate of #2070 |
I'm learning Zig and I noticed that
@cImport
takes some arbitrary typeexpression
, which seems quite confusing for me.As an expansion of #2070 I propose that
@cImport
should takecomptime []u8
c code as an argument.This will produce to syntax like this:
@cInclude
,@cDefine
and@cUndef
could be removed.The text was updated successfully, but these errors were encountered: