Files
zig/test/behavior/export_builtin.zig
Alex Rønne Petersen 476efc5b70 remove internal and link_once global linkages
These have no clear use case, no coherent definition, and incomplete/broken
compiler and linker support.

If actually needed, they can be reintroduced if someone can present a reasonable
use case along with a plan for how they should be implemented consistently in
all backends and linkers.
2026-09-26 19:12:48 +02:00

47 lines
1.4 KiB
Zig

const builtin = @import("builtin");
const std = @import("std");
const expect = std.testing.expect;
test "exporting enum value" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
const S = struct {
const E = enum(c_int) { one, two };
const e: E = .two;
comptime {
@export(&e, .{ .name = "e" });
}
};
try expect(S.e == .two);
}
test "exporting using namespace access" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
const S = struct {
const Inner = struct {
const x: u32 = 5;
};
comptime {
@export(&Inner.x, .{ .name = "foo", .linkage = .strong });
}
};
_ = S.Inner.x;
}
test "exporting comptime-known value" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
const x: u32 = 10;
@export(&x, .{ .name = "exporting_comptime_known_value_foo" });
const S = struct {
extern const exporting_comptime_known_value_foo: u32;
};
try expect(S.exporting_comptime_known_value_foo == 10);
}