mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 06:24:44 +01:00
14 lines
399 B
Zig
14 lines
399 B
Zig
const expectEqual = @import("std").testing.expectEqual;
|
|
|
|
test "comptime @ptrFromInt" {
|
|
comptime {
|
|
// Zig is able to do this at compile-time, as long as
|
|
// ptr is never dereferenced.
|
|
const ptr: *i32 = @ptrFromInt(0xdeadbee0);
|
|
const addr = @intFromPtr(ptr);
|
|
try expectEqual(usize, @TypeOf(addr));
|
|
try expectEqual(0xdeadbee0, addr);
|
|
}
|
|
}
|
|
|
|
// test
|