mirror of
https://github.com/ziglang/zig.git
synced 2024-12-02 10:02:32 +00:00
19 lines
257 B
Zig
19 lines
257 B
Zig
|
const std = @import("std");
|
||
|
|
||
|
const Foo = union {
|
||
|
float: f32,
|
||
|
int: u32,
|
||
|
};
|
||
|
|
||
|
pub fn main() void {
|
||
|
var f = Foo{ .int = 42 };
|
||
|
bar(&f);
|
||
|
}
|
||
|
|
||
|
fn bar(f: *Foo) void {
|
||
|
f.float = 12.34;
|
||
|
std.debug.print("value: {}\n", .{f.float});
|
||
|
}
|
||
|
|
||
|
// exe=fail
|