From 4e40bd86336bcb5596b30d5eac9a27f9f00208f0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 13 Mar 2019 11:54:56 -0400 Subject: [PATCH] add documentation for @"" syntax closes #1614 --- doc/langref.html.in | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/doc/langref.html.in b/doc/langref.html.in index 29e1105e280902685e7b184284bcf72a0e98e2f3..acf621c33f465f96477465c5d6b23c6032eaccaf 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -6215,6 +6215,35 @@ test "main" {

Creates a symbol in the output object file.

+

+ 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: +

+ {#code_begin|obj#} +const builtin = @import("builtin"); + +comptime { + @export("foo", internalName, builtin.GlobalLinkage.Strong); +} + +extern fn internalName() void {} + {#code_end#} +

This is equivalent to:

+ {#code_begin|obj#} +export fn foo() void {} + {#code_end#} +

Note that even when using {#syntax#}export{#endsyntax#}, {#syntax#}@"foo"{#endsyntax#} syntax can + be used to choose any string for the symbol name:

+ {#code_begin|obj#} +export fn @"A function name that is a complete sentence."() void {} + {#code_end#} +

+ 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#} {#header_close#} {#header_open|@fence#} @@ -8074,6 +8103,7 @@ pub fn build(b: *Builder) void { $ ./test $ echo $? 0 + {#see_also|export#} {#header_close#} {#header_open|Mixing Object Files#}

-- 2.54.0