zig/test/standalone/extern/exports.zig
mlugg c93e0d8618 Sema: @extern fixes
* There was an edge case where the arena could be destroyed twice on
  error: once from the arena itself and once from the decl destruction.

* The type of the created decl was incorrect (it should have been the
  pointer child type), but it's not required anyway, so it's now just
  initialized to anyopaque (which more accurately reflects what's
  actually at that memory, since e.g. [*]T may correspond to nothing).

* A runtime bitcast of the pointer was performed, meaning @extern didn't
  work at comptime. This is unnecessary: the decl_ref can just be
  initialized with the correct pointer type.
2023-03-12 18:55:23 +02:00

13 lines
242 B
Zig

var hidden: u32 = 0;
export fn updateHidden(val: u32) void {
hidden = val;
}
export fn getHidden() u32 {
return hidden;
}
const T = extern struct { x: u32 };
export var mut_val: f64 = 1.23;
export const const_val: T = .{ .x = 42 };