Re:C Macro Reflection in Zig – Zig Has Better C Interop Than...
by whitehexagon on Tuesday July 30, 2024 @03:48PM
(#41113403)
Do we know if this means the Reflection as mentioned in the article via @typeInfo will no longer work? or was it anyway comptime info? My Zig so far has been SoC level stuff, but using something like raylib or glfw is somewhere on my todo list, and this example sounds mighty useful. Anyway seems a strange thing to remove when Zig has the potential to be the new C. Hopefully also as stable for the next 30 years :)
[ Parent
| on HN ]
Re:C Macro Reflection in Zig – Zig Has Better C Interop Than...
by pbaam on Tuesday July 30, 2024 @04:27PM
(#41113784)
It will still work. If you look at the type signature of @cImport in the language reference[1], it returns a type just as @import. So you can call @typeInfo on it. But instead of writing
const win32 = @cImport({
@cInclude("windows.h");
@cInclude("winuser.h");
});
You will write: const win32 = @import("win32");
Where the module "win32" is declared in build.zig.