From 8178b4f28c72a8c7b84ece25bda7a59df8d14eb8 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Tue, 23 May 2023 21:04:12 +0200 Subject: [PATCH] Fix errors with recent compilers and C++17/20 standard (#394) - fix definition of OcTreeBase(double res) constructor (it fixes gcc12/C++20 compilation errors) - more robust detection of C++11 for Visual Studio (it fixes Visual Studio2022/C++17 compilation errors) - remove several illegal semicolon (unlikely the reason of compilation errors, but it's neater to fix that) --- octomap/include/octomap/AbstractOcTree.h | 2 +- .../include/octomap/AbstractOccupancyOcTree.h | 2 +- octomap/include/octomap/ColorOcTree.h | 2 +- octomap/include/octomap/CountingOcTree.h | 2 +- octomap/include/octomap/OcTree.h | 4 ++-- octomap/include/octomap/OcTreeBase.h | 2 +- octomap/include/octomap/OcTreeBaseImpl.h | 8 +++---- octomap/include/octomap/OcTreeDataNode.h | 4 ++-- octomap/include/octomap/OcTreeIterator.hxx | 10 ++++---- octomap/include/octomap/OcTreeStamped.h | 2 +- octomap/include/octomap/ScanGraph.h | 2 +- octomap/src/Pointcloud.cpp | 4 ++-- octomap/src/compare_octrees.cpp | 2 +- octovis/include/octovis/OcTreeDrawer.h | 10 ++++---- octovis/include/octovis/SceneObject.h | 8 +++---- octovis/include/octovis/ViewerSettings.h | 12 +++++----- .../src/extern/QGLViewer/VRender/Exporter.h | 8 +++---- octovis/src/extern/QGLViewer/camera.cpp | 4 ++-- octovis/src/extern/QGLViewer/constraint.h | 24 +++++++++---------- 19 files changed, 56 insertions(+), 56 deletions(-) diff --git a/octomap/include/octomap/AbstractOcTree.h b/octomap/include/octomap/AbstractOcTree.h index e396d28a..c1e93235 100644 --- a/octomap/include/octomap/AbstractOcTree.h +++ b/octomap/include/octomap/AbstractOcTree.h @@ -51,7 +51,7 @@ namespace octomap { friend class StaticMapInit; public: AbstractOcTree(); - virtual ~AbstractOcTree() {}; + virtual ~AbstractOcTree() {} /// virtual constructor: creates a new object of same type virtual AbstractOcTree* create() const = 0; diff --git a/octomap/include/octomap/AbstractOccupancyOcTree.h b/octomap/include/octomap/AbstractOccupancyOcTree.h index 240aedec..dd38571f 100644 --- a/octomap/include/octomap/AbstractOccupancyOcTree.h +++ b/octomap/include/octomap/AbstractOccupancyOcTree.h @@ -52,7 +52,7 @@ namespace octomap { class AbstractOccupancyOcTree : public AbstractOcTree { public: AbstractOccupancyOcTree(); - virtual ~AbstractOccupancyOcTree() {}; + virtual ~AbstractOccupancyOcTree() {} //-- IO diff --git a/octomap/include/octomap/ColorOcTree.h b/octomap/include/octomap/ColorOcTree.h index 03f8b904..5026a07b 100644 --- a/octomap/include/octomap/ColorOcTree.h +++ b/octomap/include/octomap/ColorOcTree.h @@ -192,7 +192,7 @@ namespace octomap { * StaticMemberInitializer, causing this tree failing to register. * Needs to be called from the constructor of this octree. */ - void ensureLinking() {}; + void ensureLinking() {} }; /// static member to ensure static initialization (only once) static StaticMemberInitializer colorOcTreeMemberInit; diff --git a/octomap/include/octomap/CountingOcTree.h b/octomap/include/octomap/CountingOcTree.h index f7ab115c..2b06cc7e 100644 --- a/octomap/include/octomap/CountingOcTree.h +++ b/octomap/include/octomap/CountingOcTree.h @@ -110,7 +110,7 @@ namespace octomap { * StaticMemberInitializer, causing this tree failing to register. * Needs to be called from the constructor of this octree. */ - void ensureLinking() {}; + void ensureLinking() {} }; /// static member to ensure static initialization (only once) static StaticMemberInitializer countingOcTreeMemberInit; diff --git a/octomap/include/octomap/OcTree.h b/octomap/include/octomap/OcTree.h index dcd5ac79..725ec762 100644 --- a/octomap/include/octomap/OcTree.h +++ b/octomap/include/octomap/OcTree.h @@ -59,7 +59,7 @@ namespace octomap { */ OcTree(std::string _filename); - virtual ~OcTree(){}; + virtual ~OcTree(){} /// virtual constructor: creates a new object of same type /// (Covariant return type requires an up-to-date compiler) @@ -89,7 +89,7 @@ namespace octomap { * StaticMemberInitializer, causing this tree failing to register. * Needs to be called from the constructor of this octree. */ - void ensureLinking() {}; + void ensureLinking() {} }; /// to ensure static initialization (only once) diff --git a/octomap/include/octomap/OcTreeBase.h b/octomap/include/octomap/OcTreeBase.h index d53b4056..1e600494 100644 --- a/octomap/include/octomap/OcTreeBase.h +++ b/octomap/include/octomap/OcTreeBase.h @@ -43,7 +43,7 @@ namespace octomap { template class OcTreeBase : public OcTreeBaseImpl { public: - OcTreeBase(double res) : OcTreeBaseImpl(res) {}; + OcTreeBase(double res) : OcTreeBaseImpl(res) {} /// virtual constructor: creates a new object of same type /// (Covariant return type requires an up-to-date compiler) diff --git a/octomap/include/octomap/OcTreeBaseImpl.h b/octomap/include/octomap/OcTreeBaseImpl.h index 74711c2d..7109d9cc 100644 --- a/octomap/include/octomap/OcTreeBaseImpl.h +++ b/octomap/include/octomap/OcTreeBaseImpl.h @@ -244,7 +244,7 @@ namespace octomap { virtual size_t memoryUsage() const; /// \return Memory usage of a single octree node - virtual inline size_t memoryUsageNode() const {return sizeof(NODE); }; + virtual inline size_t memoryUsageNode() const {return sizeof(NODE); } /// \return Memory usage of a full grid of the same size as the OcTree in bytes (for comparison) /// \note this can be larger than the adressable memory - size_t may not be enough to hold it! @@ -324,12 +324,12 @@ namespace octomap { typedef leaf_iterator iterator; /// @return beginning of the tree as leaf iterator - iterator begin(unsigned char maxDepth=0) const {return iterator(this, maxDepth);}; + iterator begin(unsigned char maxDepth=0) const {return iterator(this, maxDepth);} /// @return end of the tree as leaf iterator - const iterator end() const {return leaf_iterator_end;}; // TODO: RVE? + const iterator end() const {return leaf_iterator_end;} // TODO: RVE? /// @return beginning of the tree as leaf iterator - leaf_iterator begin_leafs(unsigned char maxDepth=0) const {return leaf_iterator(this, maxDepth);}; + leaf_iterator begin_leafs(unsigned char maxDepth=0) const {return leaf_iterator(this, maxDepth);} /// @return end of the tree as leaf iterator const leaf_iterator end_leafs() const {return leaf_iterator_end;} diff --git a/octomap/include/octomap/OcTreeDataNode.h b/octomap/include/octomap/OcTreeDataNode.h index febe0384..1ecdf808 100644 --- a/octomap/include/octomap/OcTreeDataNode.h +++ b/octomap/include/octomap/OcTreeDataNode.h @@ -100,9 +100,9 @@ namespace octomap { OCTOMAP_DEPRECATED(bool hasChildren() const); /// @return value stored in the node - T getValue() const{return value;}; + T getValue() const{return value;} /// sets value to be stored in the node - void setValue(T v) {value = v;}; + void setValue(T v) {value = v;} // file IO: diff --git a/octomap/include/octomap/OcTreeIterator.hxx b/octomap/include/octomap/OcTreeIterator.hxx index 5f2dd7e5..64cbdd7a 100644 --- a/octomap/include/octomap/OcTreeIterator.hxx +++ b/octomap/include/octomap/OcTreeIterator.hxx @@ -102,7 +102,7 @@ maxDepth = other.maxDepth; stack = other.stack; return *this; - }; + } /// Ptr operator will return the current node in the octree which the /// iterator is referring to @@ -220,7 +220,7 @@ * @param ptree OcTreeBaseImpl on which the iterator is used on * @param depth Maximum depth to traverse the tree. 0 (default): unlimited */ - tree_iterator(OcTreeBaseImpl const* ptree, uint8_t depth=0) : iterator_base(ptree, depth) {}; + tree_iterator(OcTreeBaseImpl const* ptree, uint8_t depth=0) : iterator_base(ptree, depth) {} /// postfix increment operator of iterator (it++) tree_iterator operator++(int){ @@ -287,7 +287,7 @@ } } - leaf_iterator(const leaf_iterator& other) : iterator_base(other) {}; + leaf_iterator(const leaf_iterator& other) : iterator_base(other) {} /// postfix increment operator of iterator (it++) leaf_iterator operator++(int){ @@ -341,7 +341,7 @@ */ class leaf_bbx_iterator : public iterator_base { public: - leaf_bbx_iterator() : iterator_base() {}; + leaf_bbx_iterator() : iterator_base() {} /** * Constructor of the iterator. The bounding box corners min and max are * converted into an OcTreeKey first. @@ -432,7 +432,7 @@ return *this; - }; + } protected: diff --git a/octomap/include/octomap/OcTreeStamped.h b/octomap/include/octomap/OcTreeStamped.h index 21cf6463..3fa648c3 100644 --- a/octomap/include/octomap/OcTreeStamped.h +++ b/octomap/include/octomap/OcTreeStamped.h @@ -116,7 +116,7 @@ namespace octomap { * StaticMemberInitializer, causing this tree failing to register. * Needs to be called from the constructor of this octree. */ - void ensureLinking() {}; + void ensureLinking() {} }; /// to ensure static initialization (only once) static StaticMemberInitializer ocTreeStampedMemberInit; diff --git a/octomap/include/octomap/ScanGraph.h b/octomap/include/octomap/ScanGraph.h index 0ababe41..7652362d 100644 --- a/octomap/include/octomap/ScanGraph.h +++ b/octomap/include/octomap/ScanGraph.h @@ -115,7 +115,7 @@ namespace octomap { public: - ScanGraph() {}; + ScanGraph() {} ~ScanGraph(); /// Clears all nodes and edges, and will delete the corresponding objects diff --git a/octomap/src/Pointcloud.cpp b/octomap/src/Pointcloud.cpp index a6d4a745..87c9e05e 100644 --- a/octomap/src/Pointcloud.cpp +++ b/octomap/src/Pointcloud.cpp @@ -38,7 +38,7 @@ #if defined(_MSC_VER) || defined(_LIBCPP_VERSION) #include - #if __cplusplus > 199711L + #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) || __cplusplus >= 201103L) #include #endif #else @@ -213,7 +213,7 @@ namespace octomap { #if defined(_MSC_VER) || defined(_LIBCPP_VERSION) samples.reserve(this->size()); samples.insert(samples.end(), this->begin(), this->end()); - #if __cplusplus > 199711L + #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) || __cplusplus >= 201103L) std::random_device r; std::mt19937 urbg(r()); std::shuffle(samples.begin(), samples.end(), urbg); diff --git a/octomap/src/compare_octrees.cpp b/octomap/src/compare_octrees.cpp index 0ab8c26b..c02ceea8 100644 --- a/octomap/src/compare_octrees.cpp +++ b/octomap/src/compare_octrees.cpp @@ -132,7 +132,7 @@ int main(int argc, char** argv) { else kld +=log(p1/p2)*p1 + log((1-p1)/(1-p2))*(1-p1); -#if __cplusplus >= 201103L +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) || __cplusplus >= 201103L) if (std::isnan(kld)){ #else if (isnan(kld)){ diff --git a/octovis/include/octovis/OcTreeDrawer.h b/octovis/include/octovis/OcTreeDrawer.h index 34d719a3..5d444057 100644 --- a/octovis/include/octovis/OcTreeDrawer.h +++ b/octovis/include/octovis/OcTreeDrawer.h @@ -62,14 +62,14 @@ namespace octomap { void setAlternativeDrawing(bool flag){m_alternativeDrawing = flag;} void enableOcTree(bool enabled = true); - void enableOcTreeCells(bool enabled = true) { m_update = true; m_drawOccupied = enabled; }; - void enableFreespace(bool enabled = true) { m_update = true; m_drawFree = enabled; }; - void enableSelection(bool enabled = true) { m_update = true; m_drawSelection = enabled; }; - void setMax_tree_depth(unsigned int max_tree_depth) { m_update = true; m_max_tree_depth = max_tree_depth;}; + void enableOcTreeCells(bool enabled = true) { m_update = true; m_drawOccupied = enabled; } + void enableFreespace(bool enabled = true) { m_update = true; m_drawFree = enabled; } + void enableSelection(bool enabled = true) { m_update = true; m_drawSelection = enabled; } + void setMax_tree_depth(unsigned int max_tree_depth) { m_update = true; m_max_tree_depth = max_tree_depth;} // set new origin (move object) void setOrigin(octomap::pose6d t); - void enableAxes(bool enabled = true) { m_update = true; m_displayAxes = enabled; }; + void enableAxes(bool enabled = true) { m_update = true; m_displayAxes = enabled; } protected: //void clearOcTree(); diff --git a/octovis/include/octovis/SceneObject.h b/octovis/include/octovis/SceneObject.h index 240c4650..d0298ab0 100644 --- a/octovis/include/octovis/SceneObject.h +++ b/octovis/include/octovis/SceneObject.h @@ -57,7 +57,7 @@ namespace octomap { public: SceneObject(); - virtual ~SceneObject(){}; + virtual ~SceneObject(){} /** * Actual draw function which will be called to visualize the object @@ -67,7 +67,7 @@ namespace octomap { /** * Clears the object's representation (will be called when it gets invalid) */ - virtual void clear(){}; + virtual void clear(){} public: //! the color mode has to be set before calling OcTreDrawer::setMap() @@ -95,8 +95,8 @@ namespace octomap { */ class ScanGraphDrawer : public SceneObject { public: - ScanGraphDrawer(): SceneObject(){}; - virtual ~ScanGraphDrawer(){}; + ScanGraphDrawer(): SceneObject(){} + virtual ~ScanGraphDrawer(){} /** * Notifies drawer of a new or changed ScanGraph, so that the internal diff --git a/octovis/include/octovis/ViewerSettings.h b/octovis/include/octovis/ViewerSettings.h index 2d9e94e3..55708682 100644 --- a/octovis/include/octovis/ViewerSettings.h +++ b/octovis/include/octovis/ViewerSettings.h @@ -40,12 +40,12 @@ class ViewerSettings : public QDialog public: ViewerSettings(QWidget *parent = 0); ~ViewerSettings(); - double getResolution(){return ui.resolution->value(); }; - void setResolution(double resolution){ui.resolution->setValue(resolution);}; - unsigned int getLaserType(){return ui.laserType->currentIndex(); }; - void setLaserType(int type){ui.laserType->setCurrentIndex(type); }; - double getMaxRange(){return ui.maxRange->value(); }; - void setMaxRange(double range){ui.maxRange->setValue(range); }; + double getResolution(){return ui.resolution->value(); } + void setResolution(double resolution){ui.resolution->setValue(resolution);} + unsigned int getLaserType(){return ui.laserType->currentIndex(); } + void setLaserType(int type){ui.laserType->setCurrentIndex(type); } + double getMaxRange(){return ui.maxRange->value(); } + void setMaxRange(double range){ui.maxRange->setValue(range); } private: Ui::ViewerSettingsClass ui; diff --git a/octovis/src/extern/QGLViewer/VRender/Exporter.h b/octovis/src/extern/QGLViewer/VRender/Exporter.h index e01b7eea..4bf5669b 100644 --- a/octovis/src/extern/QGLViewer/VRender/Exporter.h +++ b/octovis/src/extern/QGLViewer/VRender/Exporter.h @@ -60,7 +60,7 @@ namespace vrender { public: Exporter() ; - virtual ~Exporter() {}; + virtual ~Exporter() {} virtual void exportToFile(const QString& filename,const std::vector&,VRenderParams&) ; @@ -92,7 +92,7 @@ namespace vrender { public: EPSExporter() ; - virtual ~EPSExporter() {}; + virtual ~EPSExporter() {} protected: virtual void spewPoint(const Point *, QTextStream& out) ; @@ -120,7 +120,7 @@ namespace vrender class PSExporter: public EPSExporter { public: - virtual ~PSExporter() {}; + virtual ~PSExporter() {} protected: virtual void writeFooter(QTextStream& out) const ; }; @@ -129,7 +129,7 @@ namespace vrender { public: FIGExporter() ; - virtual ~FIGExporter() {}; + virtual ~FIGExporter() {} protected: virtual void spewPoint(const Point *, QTextStream& out) ; diff --git a/octovis/src/extern/QGLViewer/camera.cpp b/octovis/src/extern/QGLViewer/camera.cpp index 70dde8e3..45f028ce 100644 --- a/octovis/src/extern/QGLViewer/camera.cpp +++ b/octovis/src/extern/QGLViewer/camera.cpp @@ -199,8 +199,8 @@ void Camera::setScreenWidthAndHeight(int width, int height) \code class myCamera :: public qglviewer::Camera { - virtual qreal Camera::zNear() const { return 0.001; }; - virtual qreal Camera::zFar() const { return 100.0; }; + virtual qreal Camera::zNear() const { return 0.001; } + virtual qreal Camera::zFar() const { return 100.0; } } \endcode diff --git a/octovis/src/extern/QGLViewer/constraint.h b/octovis/src/extern/QGLViewer/constraint.h index d90d8203..cc1d8ad1 100644 --- a/octovis/src/extern/QGLViewer/constraint.h +++ b/octovis/src/extern/QGLViewer/constraint.h @@ -197,7 +197,7 @@ class QGLVIEWER_EXPORT AxisPlaneConstraint : public Constraint case MyAxisPlaneConstraint::FREE: ... break; case MyAxisPlaneConstraint::CUSTOM: ... break; } - }; + } MyAxisPlaneConstraint* c = new MyAxisPlaneConstraint(); // Note the Type conversion @@ -209,11 +209,11 @@ class QGLVIEWER_EXPORT AxisPlaneConstraint : public Constraint /*! @name Translation constraint */ //@{ /*! Overloading of Constraint::constrainTranslation(). Empty */ - virtual void constrainTranslation(Vec& translation, Frame* const frame) { Q_UNUSED(translation); Q_UNUSED(frame); }; + virtual void constrainTranslation(Vec& translation, Frame* const frame) { Q_UNUSED(translation); Q_UNUSED(frame); } void setTranslationConstraint(Type type, const Vec& direction); /*! Sets the Type() of the translationConstraintType(). Default is AxisPlaneConstraint::FREE. */ - void setTranslationConstraintType(Type type) { translationConstraintType_ = type; }; + void setTranslationConstraintType(Type type) { translationConstraintType_ = type; } void setTranslationConstraintDirection(const Vec& direction); /*! Returns the translation constraint Type(). @@ -225,7 +225,7 @@ class QGLVIEWER_EXPORT AxisPlaneConstraint : public Constraint Use Frame::setPosition() to define the position of the constrained Frame before it gets constrained. */ - Type translationConstraintType() const { return translationConstraintType_; }; + Type translationConstraintType() const { return translationConstraintType_; } /*! Returns the direction used by the translation constraint. It represents the axis direction (AxisPlaneConstraint::AXIS) or the plane normal @@ -235,20 +235,20 @@ class QGLVIEWER_EXPORT AxisPlaneConstraint : public Constraint The AxisPlaneConstraint derived classes express this direction in different coordinate system (camera for CameraConstraint, local for LocalConstraint, and world for WorldConstraint). This value can be modified with setTranslationConstraintDirection(). */ - Vec translationConstraintDirection() const { return translationConstraintDir_; }; + Vec translationConstraintDirection() const { return translationConstraintDir_; } //@} /*! @name Rotation constraint */ //@{ /*! Overloading of Constraint::constrainRotation(). Empty. */ - virtual void constrainRotation(Quaternion& rotation, Frame* const frame) { Q_UNUSED(rotation); Q_UNUSED(frame); }; + virtual void constrainRotation(Quaternion& rotation, Frame* const frame) { Q_UNUSED(rotation); Q_UNUSED(frame); } void setRotationConstraint(Type type, const Vec& direction); void setRotationConstraintType(Type type); void setRotationConstraintDirection(const Vec& direction); /*! Returns the rotation constraint Type(). */ - Type rotationConstraintType() const { return rotationConstraintType_; }; + Type rotationConstraintType() const { return rotationConstraintType_; } /*! Returns the axis direction used by the rotation constraint. This direction is defined only when rotationConstraintType() is AxisPlaneConstraint::AXIS. @@ -256,7 +256,7 @@ class QGLVIEWER_EXPORT AxisPlaneConstraint : public Constraint The AxisPlaneConstraint derived classes express this direction in different coordinate system (camera for CameraConstraint, local for LocalConstraint, and world for WorldConstraint). This value can be modified with setRotationConstraintDirection(). */ - Vec rotationConstraintDirection() const { return rotationConstraintDir_; }; + Vec rotationConstraintDirection() const { return rotationConstraintDir_; } //@} private: @@ -280,7 +280,7 @@ class QGLVIEWER_EXPORT LocalConstraint : public AxisPlaneConstraint { public: /*! Virtual destructor. Empty. */ - virtual ~LocalConstraint() {}; + virtual ~LocalConstraint() {} virtual void constrainTranslation(Vec& translation, Frame* const frame); virtual void constrainRotation (Quaternion& rotation, Frame* const frame); @@ -300,7 +300,7 @@ class QGLVIEWER_EXPORT WorldConstraint : public AxisPlaneConstraint { public: /*! Virtual destructor. Empty. */ - virtual ~WorldConstraint() {}; + virtual ~WorldConstraint() {} virtual void constrainTranslation(Vec& translation, Frame* const frame); virtual void constrainRotation (Quaternion& rotation, Frame* const frame); @@ -321,13 +321,13 @@ class QGLVIEWER_EXPORT CameraConstraint : public AxisPlaneConstraint public: explicit CameraConstraint(const Camera* const camera); /*! Virtual destructor. Empty. */ - virtual ~CameraConstraint() {}; + virtual ~CameraConstraint() {} virtual void constrainTranslation(Vec& translation, Frame* const frame); virtual void constrainRotation (Quaternion& rotation, Frame* const frame); /*! Returns the associated Camera. Set using the CameraConstraint constructor. */ - const Camera* camera() const { return camera_; }; + const Camera* camera() const { return camera_; } private: const Camera* const camera_;