tweeny icon indicating copy to clipboard operation
tweeny copied to clipboard

warning C4127: conditional expression is constant

Open HookedBehemoth opened this issue 4 years ago • 2 comments

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.

HookedBehemoth avatar Nov 02 '21 16:11 HookedBehemoth

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!

mobius3 avatar Nov 02 '21 21:11 mobius3

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);
}

HookedBehemoth avatar Nov 02 '21 23:11 HookedBehemoth