Skip to content

Conversation

@ongjunjie
Copy link
Contributor

The following code would fail to compile with "ambiguous overloaded function" error. This commit fixes it.

std::vector type = { UInt(8), UInt(8) };
f.define_extern("extern_func", args, type, dims,
                NameMangling::CPlusPlus);

The following code would fail to compile with "ambiguous overloaded
function" error. This commit fixes it.

```
std::vector type = { UInt(8), UInt(8) };
f.define_extern("extern_func", args, type, dims,
                NameMangling::CPlusPlus);
```
@mcourteaux
Copy link
Contributor

Can you give more details? What is the reason it's ambiguous? Can you give us the compiler error? Can you actually make the code snippet you included correct and complete (define all variables you pass, and define the vector template argument)?

@ongjunjie
Copy link
Contributor Author

The problem is with the two overloads below. When called as define_extern(std::string, std::vector<ExternFuncArgument>, std::vector<Type>, int, NameMangling), it's ambiguous to the compiler which overload to take and it's treated as an error. The first overload is unnecessary as its functionality is fully defined by the latter.

Halide/src/Func.h

Lines 1167 to 1183 in 08c3357

void define_extern(const std::string &function_name,
const std::vector<ExternFuncArgument> &params,
const std::vector<Type> &types, int dimensionality,
NameMangling mangling) {
define_extern(function_name, params, types,
Internal::make_argument_list(dimensionality), mangling);
}
void define_extern(const std::string &function_name,
const std::vector<ExternFuncArgument> &params,
const std::vector<Type> &types, int dimensionality,
NameMangling mangling = NameMangling::Default,
DeviceAPI device_api = DeviceAPI::Host) {
define_extern(function_name, params, types,
Internal::make_argument_list(dimensionality), mangling,
device_api);
}

Copy link
Contributor

@mcourteaux mcourteaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thanks. LGTM.

@abadams
Copy link
Member

abadams commented Jun 24, 2025

Failures are unrelated

@abadams abadams merged commit 3061b99 into halide:main Jun 24, 2025
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants