You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Variadic function-pointer types: c_import emits extern "C" fn(c_int, ...) -> c_int, which does not parse #1832
c_import renders a C variadic function-pointer type with a trailing ..., but the type grammar (parse_fn_type_node) has no ...:
use c_import("typedef int (*vfn)(int, ...);\nstatic inline int call_it(vfn f) { return f(2, 30, 12); }")
fn main:
print("x")
error: expected type
32 | type vfn = extern "C" fn(c_int, ...) -> c_int
(v0.15.2.1 and the D75 branch.) There is also no Sema type for it: TY_FN/TY_EXTERN_FN carry no variadic bit, so a call through such a pointer could not use the variadic convention.
D75 (§16.2b.5, #1678) consequence: a With function defined with ... has no function-pointer type, so the implementation refuses it as a value (is defined with ...: it is called directly (under unsafe), never used as a value); C reaches it only by its exported symbol (@[c_export]). Passing one as a callback (a logging hook typed int (*)(const char *, ...)) needs this type — spec text for it is owed (the spec states no variadic callable type).
Activity
Spec v7.9 (#1832): the type of a variadic C function as a value (#1873)
The C variadic function-pointer type: extern "C" fn(A, ..., ...) -> R (…
PROPOSED spec sentence: the type of a variadic C function as a value …