c variadic calls

This commit is contained in:
2026-06-14 15:53:45 +02:00
parent 638ca57f5c
commit 2d3d0bd266
21 changed files with 409 additions and 35 deletions
+4 -3
View File
@@ -177,8 +177,8 @@ translate_c_type :: proc(
return translated
}
function_signatures_equal :: proc(left: ast.Function, params: []ast.Param, result: types.Type) -> bool {
if left.result != result || len(left.params) != len(params) {
function_signatures_equal :: proc(left: ast.Function, params: []ast.Param, result: types.Type, variadic: bool) -> bool {
if left.result != result || left.variadic != variadic || len(left.params) != len(params) {
return false
}
for param, index in params {
@@ -282,7 +282,7 @@ load_header :: proc(state: ^State, path: string, import_span: source.Span) -> as
continue
}
duplicate = true
if !function_signatures_equal(existing, params, function_result) && len(existing.unsupported_reason) == 0 {
if !function_signatures_equal(existing, params, function_result, function.variadic) && len(existing.unsupported_reason) == 0 {
existing.unsupported_reason = fmt.aprintf(
"conflicting C declarations for '%s'",
function.name,
@@ -303,6 +303,7 @@ load_header :: proc(state: ^State, path: string, import_span: source.Span) -> as
c_abi=true,
imported=true,
has_body=false,
variadic=function.variadic,
params=params,
result=function_result,
unsupported_reason=strings.clone(unsupported_reason, state.allocator),