projectchrono / chrono

High-performance C++ library for multiphysics and multibody dynamics simulations
http://projectchrono.org
BSD 3-Clause "New" or "Revised" License
2.21k stars 465 forks source link

error on clang-6: hides overloaded virtual functions - Ubuntu 18.04 #173

Closed Tadinu closed 5 years ago

Tadinu commented 5 years ago

Hi, I got these couple of compiling errors with clang-6 on develop branch, Ubuntu 18.04. For now I have to disable those using:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Woverloaded-virtual"
    // Member declaration raising the warning.
#pragma clang diagnostic pop

as suggested in: https://stackoverflow.com/questions/18515183/c-overloaded-virtual-function-warning-by-clang

ChFrameMoving.h - TransformLocalToParent & TransformParentToLocal

/ThirdParty/chrono/include/chrono/core/ChFrameMoving.h:409:10: error: 'chrono::ChFrameMoving<double>::TransformLocalToParent' hides overloaded virtual functions [-Werror,-Woverloaded-virtual]
    void TransformLocalToParent(
         ^
/ThirdParty/chrono/include/chrono/physics/ChBodyFrame.h:28:34: note: in instantiation of template class 'chrono::ChFrameMoving<double>' requested here
class ChApi ChBodyFrame : public ChFrameMoving<double> {
                                 ^
/ThirdParty/chrono/include/chrono/core/ChFrame.h:300:28: note: hidden overloaded virtual function 'chrono::ChFrame<double>::TransformLocalToParent' declared here: different number of parameters (1 vs 2)
    virtual ChVector<Real> TransformLocalToParent(const ChVector<Real>& local) const {
                           ^
/ThirdParty/chrono/include/chrono/core/ChFrame.h:326:18: note: hidden overloaded virtual function 'chrono::ChFrame<double>::TransformLocalToParent' declared here: type mismatch at 1st parameter ('const ChFrame<double> &' vs 'const ChFrameMoving<double> &')
    virtual void TransformLocalToParent(

/ThirdParty/chrono/include/chrono/core/ChFrameMoving.h:433:10: error: 'chrono::ChFrameMoving<double>::TransformParentToLocal' hides overloaded virtual functions [-Werror,-Woverloaded-virtual]
    void TransformParentToLocal(
         ^
/ThirdParty/chrono/include/chrono/core/ChFrame.h:315:28: note: hidden overloaded virtual function 'chrono::ChFrame<double>::TransformParentToLocal' declared here: different number of parameters (1 vs 2)
    virtual ChVector<Real> TransformParentToLocal(const ChVector<Real>& parent) const {
                           ^
/ThirdParty/chrono/include/chrono/core/ChFrame.h:336:18: note: hidden overloaded virtual function 'chrono::ChFrame<double>::TransformParentToLocal' declared here: type mismatch at 1st parameter ('const ChFrame<double> &' vs 'const ChFrameMoving<double> &')
    virtual void TransformParentToLocal(
                 ^

ChLinkSpring.h - chrono::ChLinkSpring::Initialize

/ThirdParty/chrono/include/chrono/physics/ChLinkSpring.h:79:10: error: 'chrono::ChLinkSpring::Initialize' hides overloaded virtual functions [-Werror,-Woverloaded-virtual]
    void Initialize(
         ^
/ThirdParty/chrono/include/chrono/physics/ChLinkMarkers.h:95:18: note: hidden overloaded virtual function 'chrono::ChLinkMarkers::Initialize' declared here: different number of parameters (2 vs 7)
    virtual void Initialize(std::shared_ptr<ChMarker> mark1,  ///< first  marker to join
                 ^
/ThirdParty/chrono/include/chrono/physics/ChLinkMarkers.h:105:18: note: hidden overloaded virtual function 'chrono::ChLinkMarkers::Initialize' declared here: different number of parameters (3 vs 7)
    virtual void Initialize(std::shared_ptr<ChBody> mbody1,  ///< first  body to join
                 ^
/ThirdParty/chrono/include/chrono/physics/ChLinkMarkers.h:116:18: note: hidden overloaded virtual function 'chrono::ChLinkMarkers::Initialize' declared here: different number of parameters (5 vs 7)
    virtual void Initialize(
/ThirdParty/chrono/include/chrono/timestepper/ChIntegrable.h:219:18: error: 'chrono::ChIntegrableIIorder::StateSetup' hides overloaded virtual function [-Werror,-Woverloaded-virtual]
    virtual void StateSetup(ChState& x, ChStateDelta& v, ChStateDelta& a);
                 ^
/ThirdParty/chrono/include/chrono/timestepper/ChIntegrable.h:46:18: note: hidden overloaded virtual function 'chrono::ChIntegrable::StateSetup' declared here: different number of parameters (2 vs 3)
    virtual void StateSetup(ChState& y, ChStateDelta& dy) {
                 ^
In file included from 
/ThirdParty/chrono/include/chrono/physics/ChSystemNSC.h:23:
In file included from 
/ThirdParty/chrono/include/chrono/physics/ChSystem.h:41:
    virtual void SetIntegrable(ChIntegrableIIorder* intgr) {
                 ^
/ThirdParty/chrono/include/chrono/timestepper/ChTimestepper.h:69:18: note: hidden overloaded virtual function 'chrono::ChTimestepper::SetIntegrable' declared here: type mismatch at 1st parameter ('chrono::ChIntegrable *' vs 'chrono::ChIntegrableIIorder *')
    virtual void SetIntegrable(ChIntegrable* intgr) { integrable = intgr; }
rserban commented 5 years ago

You should not enable -Werror. We are aware of these issues and they are harmless (with the code working as intended). clang would simply flag them as warnings, except you instruct it to treat all warnings as errors.