Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "call of overloaded 'lerp' is ambiguous" #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mmaciola
Copy link

lerp function in src/shapes/metrics_path.cpp was causing an error:
error: call of overloaded ‘lerp(float&, const float&, float&)’ is ambiguous

/usr/include/c++/9/cmath:1919:3: note: candidate: ‘constexpr long double std::lerp(long double, long double, long double)’
 1919 |   lerp(long double __a, long double __b, long double __t) noexcept
      |   ^~~~
/usr/include/c++/9/cmath:1915:3: note: candidate: ‘constexpr double std::lerp(double, double, double)’
 1915 |   lerp(double __a, double __b, double __t) noexcept
      |   ^~~~
/usr/include/c++/9/cmath:1911:3: note: candidate: ‘constexpr float std::lerp(float, float, float)’
 1911 |   lerp(float __a, float __b, float __t) noexcept
      |   ^~~~
../submodule/rive-cpp/src/shapes/metrics_path.cpp:247:7: note: candidate: ‘float lerp(float, float, float)’
  247 | float lerp(float from, float to, float f) { return from + f * (to - from); }
      |       ^~~~
ninja: build stopped: subcommand failed.

Function was renamed to calcLerp.

lerp function in src/shapes/metrics_path.cpp was causing an error:
error: call of overloaded ‘lerp(float&, const float&, float&)’ is ambiguous

/usr/include/c++/9/cmath:1919:3: note: candidate: ‘constexpr long double std::lerp(long double, long double, long double)’
 1919 |   lerp(long double __a, long double __b, long double __t) noexcept
      |   ^~~~
/usr/include/c++/9/cmath:1915:3: note: candidate: ‘constexpr double std::lerp(double, double, double)’
 1915 |   lerp(double __a, double __b, double __t) noexcept
      |   ^~~~
/usr/include/c++/9/cmath:1911:3: note: candidate: ‘constexpr float std::lerp(float, float, float)’
 1911 |   lerp(float __a, float __b, float __t) noexcept
      |   ^~~~
../submodule/rive-cpp/src/shapes/metrics_path.cpp:247:7: note: candidate: ‘float lerp(float, float, float)’
  247 | float lerp(float from, float to, float f) { return from + f * (to - from); }
      |       ^~~~
ninja: build stopped: subcommand failed.

Function was renamed to calcLerp().
@mikerreed
Copy link
Contributor

Does the error go away if you just mark the existing lerp() function as 'static' ?

@mikerreed mikerreed self-requested a review May 14, 2022 11:21
@mmaciola
Copy link
Author

@mikerreed Nope. Marking existing lerp() function as 'static' doesn't fix the problem.
The problem is the usage of the function as there are multiple candidates, so I think renaming is the best choice. I added 'static' in the PR as the function is static but it is not essential.

@luigi-rosso
Copy link
Collaborator

luigi-rosso commented May 16, 2022

Weird that it's resolving the std::lerp, I don't think we're explicitly using namespace std; but maybe that's because your platform is including cmath.h. What are you seeing this on? Would love to repro locally so we can add a test/callout for this.

@mikerreed
Copy link
Contributor

we are unlikely to do a rename -- as that feels like running away for a larger problem -- we'd need to understand why your seeing this conflict while none of our configs see it, and then figure out where the actual problem is.

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