@export
@export
@export(comptime name: []const u8, target: var, linkage: builtin.GlobalLinkage) []const u8
Creates a symbol in the output object file.
This function can be called from a comptime block to conditionally export symbols. When target is a function with the C calling convention and linkage is Strong, this is equivalent to the export keyword used on a function:
test.zig
const builtin = @import("builtin");
comptime {
@export("foo", internalName, builtin.GlobalLinkage.Strong);
}
extern fn internalName() void {}
``` ```
$ zig build-obj test.zig
This is equivalent to:
test.zig
export fn foo() void {}
``` ```
$ zig build-obj test.zig
Note that even when using export, @"foo" syntax can be used to choose any string for the symbol name:
test.zig
export fn @"A function name that is a complete sentence."() void {}
``` ```
$ zig build-obj test.zig
When looking at the resulting object, you can see the symbol is used verbatim:
00000000000001f0 T A function name that is a complete sentence.
See also:
- Exporting a C Library
