-
-
Save Sahnvour/abf000581b3958882d3f493012f030f9 to your computer and use it in GitHub Desktop.
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 run returnaddress.zig | |
u8@7ff6c887f03f log from foo | |
reached unreachable code | |
D:\DEV\Zig\test\returnaddress.zig:5:5: 0x7ff6c887f250 in log (run.obj) | |
unreachable; | |
^ | |
D:\DEV\Zig\test\returnaddress.zig:15:12: 0x7ff6c887f03f in bar (run.obj) | |
return @inlineCall(foo, n); | |
^ | |
D:\DEV\Zig\test\returnaddress.zig:19:21: 0x7ff6c887f004 in main (run.obj) | |
warn("{}\n", bar(13)); | |
^ | |
D:\DEV\Install\zig\lib\zig\std\special\bootstrap.zig:51:40: 0x7ff6c887efe3 in ??? (run.obj) | |
std.os.windows.ExitProcess(callMain()); | |
^ | |
???:?:?: 0x7ffb24fa3dc4 in ??? (???) | |
???:?:?: 0x7ffb27223691 in ??? (???) |
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 warn = @import("std").debug.warn; | |
fn log(msg: []const u8) void { | |
warn("{} {}\n", @returnAddress(), msg); | |
unreachable; | |
} | |
fn foo(n: u32) u32 { | |
@noInlineCall(log, "log from foo"); | |
return n * 2; | |
} | |
fn bar(n: u32) u32 { | |
return @inlineCall(foo, n); | |
} | |
pub fn main() void { | |
warn("{}\n", bar(13)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment