zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 4e40bd86336bcb5596b30d5eac9a27f9f00208f0 (tree)
parent 49838a9f3eee0df33d2994b92875314363b32dfc
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed, 13 Mar 2019 11:54:56 -0400

add documentation for @"" syntax

closes #1614

Diffstat:
Mdoc/langref.html.in | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/doc/langref.html.in b/doc/langref.html.in @@ -6215,6 +6215,35 @@ test "main" { <p> Creates a symbol in the output object file. </p> + <p> + This function can be called from a {#link|comptime#} block to conditionally export symbols. + When {#syntax#}target{#endsyntax#} is a function with the C calling convention and + {#syntax#}linkage{#endsyntax#} is {#syntax#}Strong{#endsyntax#}, this is equivalent to + the {#syntax#}export{#endsyntax#} keyword used on a function: + </p> + {#code_begin|obj#} +const builtin = @import("builtin"); + +comptime { + @export("foo", internalName, builtin.GlobalLinkage.Strong); +} + +extern fn internalName() void {} + {#code_end#} + <p>This is equivalent to:</p> + {#code_begin|obj#} +export fn foo() void {} + {#code_end#} + <p>Note that even when using {#syntax#}export{#endsyntax#}, {#syntax#}@"foo"{#endsyntax#} syntax can + be used to choose any string for the symbol name:</p> + {#code_begin|obj#} +export fn @"A function name that is a complete sentence."() void {} + {#code_end#} + <p> + When looking at the resulting object, you can see the symbol is used verbatim: + </p> + <pre>00000000000001f0 T A function name that is a complete sentence.</pre> + {#see_also|Exporting a C Library#} {#header_close#} {#header_open|@fence#} @@ -8074,6 +8103,7 @@ pub fn build(b: *Builder) void { $ ./test $ echo $? 0</code></pre> + {#see_also|export#} {#header_close#} {#header_open|Mixing Object Files#} <p>