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

warning C4127: conditional expression is constant #28

Open
HookedBehemoth opened this issue Nov 2, 2021 · 2 comments
Open

warning C4127: conditional expression is constant #28

HookedBehemoth opened this issue Nov 2, 2021 · 2 comments

Comments

@HookedBehemoth
Copy link

Compiling this with MSVC 16 on C++20 and tweening a glm::vec3 I get the following warning:

[build] [...]\lib\tweeny\include\easingresolve.h(44,35): warning C4127: conditional expression is constant [[...]\build\opengl-tests.vcxproj]
[build] [...]\lib\tweeny\include\easingresolve.h(43,1): message : consider using 'if constexpr' statement instead [[...]\build\opengl-tests.vcxproj]
[build] [...]\lib\tweeny\include\easingresolve.h(43): message : while compiling class template member function 'void tweeny::detail::easingresolve<1,TypeTuple,FunctionTuple>::impl(FunctionTuple &)' [[...]\build\opengl-tests.vcxproj]
[build]           with
[build]           [
[build]               TypeTuple=std::array<glm::vec<3,float,glm::packed_highp>,1>,
[build]               FunctionTuple=std::tuple<std::function<glm::vec3 (float,glm::vec3,glm::vec3)>>
[build]           ]
...

Adding the constexpr removes the warning but you should know more.

@mobius3
Copy link
Owner

mobius3 commented Nov 2, 2021

And... did it worked? did it produced the expected results? Testing a vec3 was something that I wanted to do but never got time to.

Can you share the code you used to instantiate the tween or maybe a small file enough to reproduce the warning, does it happen with other types? Does it happen under C++17/14/11 flags?

Thanks!

@HookedBehemoth
Copy link
Author

Yes it works as expected.

The warning appears under 20, 17 and 14. Not under 11.
sample code

#include <tweeny.h>
#include <glm.hpp>

int main()
{
    const auto start = glm::vec3(0.0f, 0.0f, -3.0f);
    const auto end = glm::vec3(0.0f, 0.0f, -5.0f);

    auto tween = tweeny::from(start)
                     .to(end)
                     .during(500);

    tween.step(1);
}

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

No branches or pull requests

2 participants