Skip to content

Unable to call variadic function with no named parameters even though it is useful since C23 #123773

Closed
@HomelikeBrick42

Description

You have always been able to define variadic functions in C with no named parameters, but until C23 it was not useful because you could never access those arguments
Since C23 the va_start macro in C has been changed to no longer require a parameter name, so now being able to call variadic functions with no named parameters is actually useful

extern "C" {
    fn foo(...);
}

I would expect this to compile, if there was a function foo defined in C like so

void foo(...) { // the ... is optional pre-c23, but since C23 its required to make the function variadic
    // whatever implementation
}

But instead this does not compile

error: C-variadic function must be declared with at least one named argument
 --> src\lib.rs:2:12
  |
2 |     fn foo(...);
  |            ^^^

Meta

rustc --version --verbose:

binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-pc-windows-msvc
release: 1.76.0
LLVM version: 17.0.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

A-FFIArea: Foreign function interface (FFI)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions