E0045 Variadic on Non-C ABI Fix
Written December 2, 2026 · Tested with Rust 1.99.1 · 13 min read
- The rule underneath: ... is a C calling-convention feature
- How to read the diagnostic
- The first failure: the index example
- The same error with more parameters, with none, and in an unsafe block
Written December 2, 2026
Tested with Rust 1.99.1
What this guide is
Error E0045 means a C-variadic parameter list - the trailing ... in a function declaration - was put on a function whose calling convention cannot carry it. The error codes index puts the reason plainly: Rust only supports variadic parameters for interoperability with C code in its FFI, so variadic parameters can only be used with functions using the C ABI.
In the shapes probed in this guide, E0045 fires for a variadic declaration inside an extern "Rust" block, with one named parameter, with two, with none, and in an unsafe extern "Rust" block. It does not fire for the same declaration under a C-compatible ABI - extern "C", extern "C-unwind", extern "system", extern "sysv64", extern "win64", and extern "efiapi" declarations all compiled in the probed shapes - and it is not the code for three neighboring shapes: an ABI the target does not support, which draws E0570, a variadic list on an ordinary function definition, which draws uncoded errors, and an invalid argument passed to a C variadic function, which draws E0617. This guide shows the E0045 shapes, the neighboring shapes that are not this error, and the repairs.
Build every program in this guide with rustc --edition 2021. In the compiler transcripts, the file names are the bare names shown on the command line.
The rule underneath: ... is a C calling-convention feature
A trailing ... does not mean "any number of Rust arguments". It is the C variable argument list: the caller passes extra arguments under the C ABI's rules, and the callee reads them under those same rules. The "Rust" calling convention has no such rules, so the compiler refuses the combination at the declaration, before any call is made.
That gives the two honest repairs. If the function really is a C variadic function - the usual case, because the declaration exists to call into C - keep the ... and change the ABI to a C-compatible one. If the function is really a Rust function, keep the ABI and drop the ..., replacing it with the fixed parameters the function actually takes, or with an ordinary Rust definition.
How to read the diagnostic
The E0045 header names the calling convention that was used: "C-variadic functions with the "Rust" calling convention are not supported", in the probed shapes. The span underlines the whole declaration, from fn through the ..., and the note under it reads "C-variadic function must have a compatible calling convention". There is no help block in the probed E0045 shapes - the diagnostic names the declaration and the problem, and the ABI string on the block is the thing to change.
The count follows the declarations, in the probed shapes: a program with one variadic declaration in an extern "Rust" block drew exactly one error[E0045], and a program with two such declarations in one block drew exactly two, one per declaration, with "aborting due to 2 previous errors". No other error code rode along in any probed pure E0045 shape.
The first failure: the index example
The index's erroneous example, verbatim:
#![allow(unused)]
fn main() {
extern "Rust" {
fn foo(x: u8, ...); // error!
}
}
error[E0045]: C-variadic functions with the "Rust" calling convention are not supported
--> fail_index.rs:4:5
|
4 | fn foo(x: u8, ...); // error!
| ^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0045`.
Exactly one E0045, and nothing else. The parameter types are not the problem - one named u8 parameter is ordinary - and the ... is written correctly; only the ABI on the block is wrong for a variadic list.
The same error with more parameters, with none, and in an unsafe block
The named parameters do not matter, in the probed shapes. A declaration with two named parameters before the ... draws exactly one E0045 with the same header and note as the index example:
fn main() {
extern "Rust" { fn foo(x: u8, y: u16, ...); }
}
error[E0045]: C-variadic functions with the "Rust" calling convention are not supported
--> fail_rust_two.rs:2:17
|
2 | extern "Rust" { fn foo(x: u8, y: u16, ...); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0045`.
A declaration with no named parameter at all - the ... alone - draws exactly one E0045 in the probed shape as well:
fn main() {
extern "Rust" { fn foo(...); }
}
error[E0045]: C-variadic functions with the "Rust" calling convention are not supported
--> fail_rust_only_var.rs:2:17
|
2 | extern "Rust" { fn foo(...); }
| ^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0045`.
Adding unsafe to the block does not save it. An unsafe extern "Rust" block containing the same declaration draws exactly one E0045 in the probed shape, with the same header and note:
error[E0045]: C-variadic functions with the "Rust" calling convention are not supported
--> fail_unsafe_rust.rs:2:24
|
2 | unsafe extern "Rust" { fn foo(x: u8, ...); }
| ^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0045`.
The shapes that are not this error
An unsupported ABI is refused before, or alongside, the variadic question. A variadic declaration under extern "aapcs" drew exactly one E0570, "is not a supported ABI for the current target", and no E0045 in the probed shape:
fn main() {
extern "aapcs" { fn foo(x: u8, ...); }
}
error[E0570]: "aapcs" is not a supported ABI for the current target
--> fail_aapcs.rs:2:8
|
2 | extern "aapcs" { fn foo(x: u8, ...); }
| ^^^^^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0570`.
Two other unsupported ABIs probed behaved differently again: variadic declarations under extern "stdcall" and under extern "fastcall" each drew E0570 and E0045 together, two previous errors in each probed shape - the ABI is unsupported on this target and, separately, not a convention that supports a C variable argument list. Check which codes you have: E0045 alone points at the ABI choice, while an E0570 in the output means the ABI itself is not available on the target at all, in the probed shapes.
A variadic list on an ordinary function definition is not this error either. fn foo(x: u8, ...) {} at the top level drew no E0045 and no other error code in the probed shape: it drew uncoded errors - "missing pattern for ... argument" and "... is not supported for non-extern functions", whose help text states that only extern "C" and extern "C-unwind" functions may have a C variable argument list. The same uncoded shape appeared for a variadic method definition inside an impl block in the probed shape. A definition is the wrong place to fix an E0045 declaration, and a declaration is the wrong place to fix these uncoded errors - they are different shapes that happen to share the ....
Passing the wrong type of argument to a C variadic function is a third neighbor. Calling a declared extern "C" variadic function with an f32 as the variadic argument draws exactly one E0617, "can't pass f32 to variadic function", and no E0045 in the probed shape:
extern "C" { fn foo(x: u8, ...); }
fn main() { unsafe { foo(1, 1.0f32); } }
error[E0617]: can't pass `f32` to variadic function
--> neighbour_call_float.rs:2:29
|
2 | fn main() { unsafe { foo(1, 1.0f32); } }
| ^^^^^^
|
help: cast the value to `c_double`
|
2 | fn main() { unsafe { foo(1, 1.0f32 as c_double); } }
| +++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0617`.
That error is about a call, not a declaration: its declaration is already under the C ABI, and its fix is the cast the help block names, not an ABI change.
Related guides
For an invalid argument passed to a variadic function, the neighboring code is E0617. For a variadic argument passed to a function that is not variadic, or a variadic declaration under an ABI the target does not support, check E0570's shape above before reaching for this guide's fix.
The repairs
Every repair below starts from the same observation: the ... and the ABI disagree, so either the ABI moves to a C-compatible one, or the ... goes away.
Change the block to extern "C". This is the direct fix for the index shape, and it is the fix the index page itself gives. With only the ABI string changed, the declaration compiled and the program ran in the probed shape, printing declared:
fn main() { println!("declared"); }
extern "C" { fn foo(x: u8, ...); }
declared
The declaration is only a declaration - nothing calls foo in that program - so the run proves the declaration is accepted, not that a call works. The next repair proves a call.
Call a real C variadic function declared the same way. A printf declaration under extern "C" with a ... compiled and ran in the probed shape, printing value 42 for the value passed as the variadic argument:
extern "C" { fn printf(fmt: *const u8, ...) -> i32; }
fn main() { unsafe { printf("value %d\n\0".as_ptr(), 42); } }
value 42
Other C-compatible ABIs accept the declaration too, in the probed shapes. Declarations under extern "C-unwind", extern "system", extern "sysv64", extern "win64", and extern "efiapi" each compiled, and each program ran printing declared - the same declaration-only shape as the extern "C" repair above. Pick the ABI the foreign function actually uses; extern "C" is the default choice when the function is an ordinary C function, and extern "system" is the portable choice where the system ABI differs from C on some targets, in the probed shapes.
Drop the ... and keep the Rust ABI. If the foreign function is not actually variadic, the declaration is wrong in the other direction: removing the ... from the index shape compiled and ran in the probed shape, printing declared:
fn main() { println!("declared"); }
extern "Rust" { fn foo(x: u8); }
declared
Replace the ... with fixed parameters when the function is ordinary Rust code. A plain definition taking the two values it needs compiled and ran in the probed shape, printing 3 for the inputs 1 and 2:
fn foo(x: u8, y: u8) -> u16 { x as u16 + y as u16 }
fn main() { println!("{}", foo(1,2)); }
3
Define a C variadic function in Rust with a named variadic pattern. A definition is a different shape from a declaration: in the probed shape, unsafe extern "C" fn foo(x: u8, _: ...) {} compiled and the program ran, printing defined:
unsafe extern "C" fn foo(x: u8, _: ...) {}
fn main() { println!("defined"); }
defined
The same definition written without the pattern - unsafe extern "C" fn foo(x: u8, ...) {} - drew uncoded "missing pattern for ... argument" errors and no E0045 in the probed shape, so the _: ... pattern is part of this repair, not decoration.
One more accepted shape compiled and ran in the probes without becoming a separate repair above: a variadic declaration in an extern block with no ABI string printed declared in the probed shape, with a deprecation warning asking for the ABI to be written explicitly as extern "C" - write the ABI out rather than relying on the default.
Fixes in reach order
First, read the ABI on the block. In the probed shapes, E0045 is the declaration's ABI disagreeing with its ...: the header names the calling convention that was used. If another code rides along - E0570 in the probed stdcall and fastcall shapes - the ABI itself is also unsupported on the target, and changing only the variadic list will not clear the program.
Second, if the function is a C variadic function, change the ABI to extern "C" - or to the C-compatible ABI the function actually uses, in the probed shapes. That is the whole repair for the index shape.
Third, if the function is not variadic, drop the ... and keep the ABI, as in the probed shape above.
Fourth, if the function is ordinary Rust code rather than a foreign declaration, write it as an ordinary definition with fixed parameters - a ... on a definition draws uncoded errors, not E0045, in the probed shapes.
Last, check whether the error is at a call rather than a declaration. In the probed shape, passing an f32 to a C variadic function drew E0617, whose fix is a cast at the call, not an ABI change at the declaration.
Decision summary
E0045 fired in the probed shapes for a variadic declaration under the "Rust" calling convention: the index example fn foo(x: u8, ...) in an extern "Rust" block (exactly one E0045), the same declaration with two named parameters (exactly one E0045), with no named parameter (exactly one E0045), and in an unsafe extern "Rust" block (exactly one E0045). Two variadic declarations in one extern "Rust" block drew exactly two E0045 errors, one per declaration. It did not fire for the same declaration under extern "C", extern "C-unwind", extern "system", extern "sysv64", extern "win64", or extern "efiapi", each of which compiled in the probed shapes, for a variadic declaration under extern "aapcs", which drew exactly one E0570, for variadic declarations under extern "stdcall" or extern "fastcall", which drew E0570 and E0045 together, for a variadic list on an ordinary function or method definition, which drew uncoded errors, or for passing an f32 to a C variadic function, which drew exactly one E0617. The repairs that compiled and ran were changing the block to extern "C" (printing declared), calling a real C variadic printf declared that way (printing value 42), dropping the ... and keeping the Rust ABI (printing declared), replacing the ... with fixed parameters in an ordinary definition (printing 3), and defining a C variadic function with a _: ... pattern (printing defined).
Checklist
- E0045 is about the ABI, in the probed shapes: a C variable argument list needs a compatible calling convention, and the
"Rust"convention is not one. - The named parameters do not matter, in the probed shapes: declarations with one named parameter, with two, and with none all drew E0045 under the Rust ABI.
- Adding
unsafeto the block does not change the outcome, in the probed shape: anunsafe extern "Rust"variadic declaration drew E0045 just as the plain block did. - The error count follows the declarations, in the probed shapes: two variadic declarations in one Rust-ABI block drew two E0045 errors.
- An unsupported ABI is a different problem that can ride along, in the probed shapes:
aapcsdrew E0570 alone, whilestdcallandfastcalldrew E0570 and E0045 together - check every code in the output before choosing a fix. - A
...belongs on a declaration or on a C-ABI definition with a pattern, in the probed shapes: on an ordinary definition it drew uncoded errors, and on a C definition without the_: ...pattern it drew uncoded errors too.
Sources
- Rust error codes index, E0045 - variadic parameters have been used on a non-C ABI function; Rust only supports variadic parameters for interoperability with C code in its FFI, so they can only be used with functions using the C ABI, and the fix given is to put them in an
extern "C"block; the erroneous example declaresfn foo(x: u8, ...)inside anextern "Rust"block. - Rust error codes index, E0570 - the requested ABI is unsupported by the current target; the neighboring code drawn in the probed shapes by variadic declarations under unsupported ABIs.
- Rust error codes index, E0617 - an invalid type of variable was passed into a variadic function, and certain types must be cast before passing; the neighboring code drawn in the probed shape by passing an
f32to a C variadic function.
Keep Exploring
The full Rust hub \u2014 ownership, structs and enums, async, and measured comparisons.
Every guide on the site in one list, grouped by topic.
Every browser-only checker and verifier on the site.
The C++, Python, Sysadmin, Rust, Go, and TypeScript hubs.