Last active
July 31, 2018 20:13
-
-
Save moysesb/9d3c82c0f1812045d344d3f70d33a9e2 to your computer and use it in GitHub Desktop.
zig compiler bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef const struct InvocationTable_ *VM; | |
struct VM_ { | |
const struct InvocationTable_ *functions; | |
}; | |
struct InvocationTable_ { | |
int (*GetVM)(VM *vm); | |
}; | |
int agent_callback(VM *vm, char *options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ~> zig translate-c --verbose-cimport vm.h | |
pub const VM = ?[*]const struct_InvocationTable_; | |
pub const struct_InvocationTable_ = extern struct { | |
GetVM: ?extern fn(?[*]VM) c_int, | |
}; | |
pub const struct_VM_ = extern struct { | |
functions: ?[*]const struct_InvocationTable_, | |
}; | |
//excised output from stdlib.h etc | |
pub const InvocationTable_ = struct_InvocationTable_; | |
pub const VM_ = struct_VM_; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const vm = @cImport({ @cInclude("vm.h"); }); | |
export fn agent_callback(_vm: [*]vm.VM, options: [*]u8) i32 { | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zig -isystem . build-lib vm.zig | |
vm.zig:1:12: error: compiler bug: @cImport generated invalid zig code | |
const vm = @cImport({ @cInclude("vm.h"); }); | |
^ | |
?.c:1:1: note: 'VM' depends on itself | |
TODO: remember C source location to display here | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment