diff options
| author | Manlio Perillo <manlio.perillo@gmail.com> | 2022-12-12 11:32:48 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-12-13 15:09:08 -0500 |
| commit | 35c6fe665c7f3f8ba14aaee97c832000cbf5ddc2 (patch) | |
| tree | 673e7a2588b379734b4ed9c231cd4f58c23dde8c /doc/langref.html.in | |
| parent | 332020f3103366d54c518be2e8a57cf440a254de (diff) | |
| download | zig-35c6fe665c7f3f8ba14aaee97c832000cbf5ddc2.tar.gz zig-35c6fe665c7f3f8ba14aaee97c832000cbf5ddc2.zip | |
langref: document extern variadic functions
Add a new subsection within the C section, documenting extern variadic
functions.
Diffstat (limited to 'doc/langref.html.in')
| -rw-r--r-- | doc/langref.html.in | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/langref.html.in b/doc/langref.html.in index 6b899a0b4f..eb89b3d2a2 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -10802,6 +10802,33 @@ pub const MAKELOCAL = @compileError("unable to translate C expr: unexpected toke <p>{#syntax#}ptr_to_struct_array[index].struct_member{#endsyntax#}</p> {#header_close#} + {#header_open|C Variadic Functions#} + <p>Zig supports extern variadic functions.</p> + {#code_begin|test|variadic_function#} + {#link_libc#} + {#code_verbose_cimport#} +const std = @import("std"); +const testing = std.testing; + +pub extern "c" fn printf(format: [*:0]const u8, ...) c_int; + +test "variadic function" { + try testing.expect(printf("Hello, world!\n") == 14); + try testing.expect(@typeInfo(@TypeOf(printf)).Fn.is_var_args); +} + {#code_end#} + <p> + Non extern variadic functions are currently not implemented, but there + is an accepted proposal. See <a href="https://github.com/ziglang/zig/issues/515">#515</a>. + </p> + {#code_begin|obj_err|non-extern function is variadic#} +export fn printf(format: [*:0]const u8, ...) c_int { + _ = format; + + return 0; +} + {#code_end#} + {#header_close#} {#header_open|Exporting a C Library#} <p> One of the primary use cases for Zig is exporting a library with the C ABI for other programming languages |
