Skip to content

Commit

Permalink
Fix compilation errors with C++20 (#4098)
Browse files Browse the repository at this point in the history
### What
* Closes #4090

I tried getting these tests running on CI too, but after 2h I gave up.
Andreas has volunteered to try a bit more, so let's hold off merging
this PR until we can reproduce the problems on CI.
See #4097 if you dare

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/4098) (if
applicable)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/4098)
- [Docs
preview](https://rerun.io/preview/a69d06b8a84b78469192f341bebdfc32dc7936cc/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/a69d06b8a84b78469192f341bebdfc32dc7936cc/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
  • Loading branch information
emilk authored Oct 31, 2023
1 parent adcb476 commit c7cfefd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ function(set_default_warning_settings target)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # match both "Clang" and "AppleClang"
target_compile_options(${target} PRIVATE
-Wc++17-compat-pedantic
-Wc++20-compat-pedantic
-Wpre-c2x-compat-pedantic
-Wc99-extensions
-Wgnu
-Wnon-gcc
Expand Down
14 changes: 8 additions & 6 deletions rerun_cpp/src/rerun/datatypes/quaternion.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions rerun_cpp/src/rerun/datatypes/quaternion_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,34 @@ namespace rerun {

/// Construct Quaternion from x/y/z/w values.
static Quaternion from_xyzw(float x, float y, float z, float w) {
return Quaternion{x, y, z, w};
return Quaternion::from_xyzw({x, y, z, w});
}

/// Construct Quaternion from w/x/y/z values.
static Quaternion from_wxyz(float w, float x, float y, float z) {
return Quaternion{x, y, z, w};
return Quaternion::from_xyzw(x, y, z, w);
}

/// Construct Quaternion from x/y/z/w array.
static Quaternion from_xyzw(std::array<float, 4> xyzw_) {
return Quaternion{xyzw_};
Quaternion q;
q.xyzw = xyzw_;
return q;
}

/// Construct Quaternion from w/x/y/z array.
static Quaternion from_wxyz(std::array<float, 4> wxyz_) {
return Quaternion{wxyz_[1], wxyz_[2], wxyz_[3], wxyz_[0]};
return Quaternion::from_xyzw(wxyz_[1], wxyz_[2], wxyz_[3], wxyz_[0]);
}

/// Construct Quaternion from x/y/z/w float pointer.
static Quaternion from_xyzw(const float* xyzw_) {
return Quaternion{xyzw_[0], xyzw_[1], xyzw_[2], xyzw_[3]};
return Quaternion::from_xyzw(xyzw_[0], xyzw_[1], xyzw_[2], xyzw_[3]);
}

/// Construct Quaternion from w/x/y/z float pointer.
static Quaternion from_wxyz(const float* wxyz_) {
return Quaternion{wxyz_[1], wxyz_[2], wxyz_[3], wxyz_[0]};
return Quaternion::from_xyzw(wxyz_[1], wxyz_[2], wxyz_[3], wxyz_[0]);
}

float x() const {
Expand Down
2 changes: 1 addition & 1 deletion rerun_cpp/tests/archetypes/transform3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ SCENARIO(
}

SECTION("TranslationRotationScale") {
const auto rotation = rrd::Quaternion{1.0f, 2.0f, 3.0f, 4.0f};
const auto rotation = rrd::Quaternion::from_xyzw(1.0f, 2.0f, 3.0f, 4.0f);

Transform3D manual;
rrd::TranslationRotationScale3D translation_rotation_scale;
Expand Down

0 comments on commit c7cfefd

Please sign in to comment.