Created
February 23, 2019 22:22
-
-
Save emekoi/110d2f7e410e094e988a5aa0925e948d 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
const std = @import("std"); | |
const Foo = struct { | |
bar: usize, | |
bytes: []u8 | |
}; | |
pub fn foo(bytes: []u8) void { | |
var boo = @fieldParentPtr(Foo, "bytes", &bytes); | |
std.debug.warn("{}\n", @ptrToInt(boo)); | |
} | |
pub fn main() !void { | |
var bax = try std.debug.global_allocator.create(Foo); | |
bax.bytes = try std.debug.global_allocator.alloc(u8, 10); | |
std.debug.warn("{}\n", @ptrToInt(bax)); | |
foo(bax.bytes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment