@export
@export
@export(target: var, comptime options: std.builtin.ExportOptions) void
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 options.linkage is Strong, this is equivalent to the export keyword used on a function:
test.zig
comptime {
@export(internalName, .{ .name = "foo", .linkage = .Strong });
}
fn internalName() callconv(.C) 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
