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 compilation error in drawRefAxis function #153

Merged
merged 1 commit into from
Feb 21, 2022

Conversation

traversaro
Copy link
Member

@traversaro traversaro commented Feb 15, 2022

In some platforms, you can't have an implicit narrowing cast in inizializer lists, unless the argument is constant. Before this PR, the code resulted in this error:

2022-02-14T19:54:21.2244330Z /Users/runner/work/robotology-superbuild/robotology-superbuild/src/event-driven/lib/src/vIPT.cpp:493:31: error: non-constant-expression cannot be narrowed from type 'double' to 'float' in initializer list [-Wc++11-narrowing]
2022-02-14T19:54:21.2346020Z     std::array<float, 3> r = {a*x, a*y, a*z};
2022-02-14T19:54:21.2446960Z                               ^~~
2022-02-14T19:54:21.2548470Z /Users/runner/work/robotology-superbuild/robotology-superbuild/src/event-driven/lib/src/vIPT.cpp:493:31: note: insert an explicit cast to silence this issue
2022-02-14T19:54:21.2649640Z     std::array<float, 3> r = {a*x, a*y, a*z};
2022-02-14T19:54:21.2750520Z                               ^~~
2022-02-14T19:54:21.2851510Z                               static_cast<float>( )
2022-02-14T19:54:21.2945990Z /Users/runner/work/robotology-superbuild/robotology-superbuild/src/event-driven/lib/src/vIPT.cpp:493:36: error: non-constant-expression cannot be narrowed from type 'double' to 'float' in initializer list [-Wc++11-narrowing]
2022-02-14T19:54:21.3052730Z     std::array<float, 3> r = {a*x, a*y, a*z};
2022-02-14T19:54:21.3153570Z                                    ^~~
2022-02-14T19:54:21.3255100Z /Users/runner/work/robotology-superbuild/robotology-superbuild/src/event-driven/lib/src/vIPT.cpp:493:36: note: insert an explicit cast to silence this issue
2022-02-14T19:54:21.3356110Z     std::array<float, 3> r = {a*x, a*y, a*z};
2022-02-14T19:54:21.3456980Z                                    ^~~
2022-02-14T19:54:21.3558010Z                                    static_cast<float>( )
2022-02-14T19:54:21.3659480Z /Users/runner/work/robotology-superbuild/robotology-superbuild/src/event-driven/lib/src/vIPT.cpp:493:41: error: non-constant-expression cannot be narrowed from type 'double' to 'float' in initializer list [-Wc++11-narrowing]
2022-02-14T19:54:21.3760690Z     std::array<float, 3> r = {a*x, a*y, a*z};
2022-02-14T19:54:21.3860890Z                                         ^~~
2022-02-14T19:54:21.3962540Z /Users/runner/work/robotology-superbuild/robotology-superbuild/src/event-driven/lib/src/vIPT.cpp:493:41: note: insert an explicit cast to silence this issue
2022-02-14T19:54:21.4062140Z     std::array<float, 3> r = {a*x, a*y, a*z};
2022-02-14T19:54:21.4163080Z                                         ^~~
2022-02-14T19:54:21.4264100Z                                         static_cast<float>( )
2022-02-14T19:54:21.4364440Z 12 warnings and 3 errors generated.

Fix robotology/robotology-superbuild#1033 .

@traversaro
Copy link
Member Author

In some platforms

After a few more check "in some platforms" is actually macOS/clang.

@traversaro
Copy link
Member Author

fyi @arrenglover

@arrenglover arrenglover merged commit 1362bcb into master Feb 21, 2022
@arrenglover arrenglover deleted the traversaro-patch-1 branch February 21, 2022 13:39
@arrenglover
Copy link
Collaborator

thanks @traversaro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants