File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
src/doc/unstable-book/src Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ # ` c_variadic `
2+
3+ The tracking issue for this feature is: [ #44930 ]
4+
5+ [ #44930 ] : https://github.com/rust-lang/rust/issues/44930
6+
7+ ------------------------
8+
9+ The ` c_variadic ` language feature enables C-variadic functions to be
10+ defined in Rust. The may be called both from within Rust and via FFI.
11+
12+ ## Examples
13+
14+ ``` rust
15+ #![feature(c_variadic)]
16+
17+ pub unsafe extern " C" fn add (n : usize , mut args : ... ) -> usize {
18+ let mut sum = 0 ;
19+ for _ in 0 .. n {
20+ sum += args . arg :: <usize >();
21+ }
22+ sum
23+ }
24+ ```
Original file line number Diff line number Diff line change 1+ # ` c_variadic `
2+
3+ The tracking issue for this feature is: [ #44930 ]
4+
5+ [ #44930 ] : https://github.com/rust-lang/rust/issues/44930
6+
7+ ------------------------
8+
9+ The ` c_variadic ` library feature exposes the ` VaList ` structure,
10+ Rust's analogue of C's ` va_list ` type.
11+
12+ ## Examples
13+
14+ ``` rust
15+ #![feature(c_variadic)]
16+
17+ use std :: ffi :: VaList ;
18+
19+ pub unsafe extern " C" fn vadd (n : usize , mut args : VaList ) -> usize {
20+ let mut sum = 0 ;
21+ for _ in 0 .. n {
22+ sum += args . arg :: <usize >();
23+ }
24+ sum
25+ }
26+ ```
You can’t perform that action at this time.
0 commit comments