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 errors with C++20 #4098

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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
emilk marked this conversation as resolved.
Show resolved Hide resolved
-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
Loading