From f30d9f7c0531946b1aba4dc46946318d6281806f Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 21 Apr 2020 12:10:32 +0300 Subject: [PATCH] Fight warnings (continue) --- CMakeLists.txt | 39 ++++++++++++++++++++++++++++ src/CCC/BatchManager_CCC.cxx | 2 +- src/Core/BatchManager.cxx | 18 ++++++------- src/Core/BatchManagerCatalog.hxx | 4 +-- src/Core/CommunicationProtocolSH.cxx | 12 ++++----- src/Core/Log.hxx | 4 +-- src/Core/MpiImpl.cxx | 20 +++++++------- src/Core/ParameterTypeMap.hxx | 4 +-- src/Core/Versatile.cxx | 7 ++--- src/Core/Versatile.hxx | 4 +-- src/LSF/BatchManager_LSF.cxx | 2 +- src/Local/BatchManager_Local.cxx | 2 +- src/PBS/BatchManager_PBS.cxx | 2 +- src/SGE/BatchManager_SGE.cxx | 2 +- src/Vishnu/BatchManager_Vishnu.cxx | 2 +- 15 files changed, 82 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c89c354..a120733 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,45 @@ IF(LIBBATCH_LOCAL_SUBMISSION) LIBBATCH_FIND_ALL_LOCAL_COMMANDS() ENDIF() +INCLUDE(CheckCXXCompilerFlag) + +SET(LIBBATCH_NO_CXX11_SUPPORT FALSE CACHE BOOL "Switch OFF C++-11 standard") +IF(NOT LIBBATCH_NO_CXX11_SUPPORT) + # C++11 support + CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + IF(COMPILER_SUPPORTS_CXX11) + MESSAGE(STATUS "Enable C++11 support") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + ELSE() + CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) + IF(COMPILER_SUPPORTS_CXX0X) + MESSAGE(STATUS "Enable C++0x support") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + ELSE() + MESSAGE(WARNING "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.") + ENDIF() + ENDIF() +ENDIF() + +IF(NOT (WIN32 OR APPLE)) + SET(LIBBATCH_DEBUG_WARNINGS FALSE CACHE BOOL "Print more compiler warnings") + SET(LIBBATCH_TREAT_WARNINGS_AS_ERRORS FALSE CACHE BOOL "Treat compiler warnings as errors") + IF(LIBBATCH_DEBUG_WARNINGS) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic") + ENDIF() + IF(LIBBATCH_TREAT_WARNINGS_AS_ERRORS) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + ENDIF() +ENDIF() + +# Compiler flag to disable treating alternative C++ tokens (compatibility with MSVS) +CHECK_CXX_COMPILER_FLAG("-fno-operator-names" COMPILER_SUPPORTS_NO_OPERATOR_NAMES) +IF(COMPILER_SUPPORTS_NO_OPERATOR_NAMES) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-operator-names") +ENDIF() + # Prerequisites detection: # ======================== FIND_PACKAGE(LibbatchPThread REQUIRED) diff --git a/src/CCC/BatchManager_CCC.cxx b/src/CCC/BatchManager_CCC.cxx index c69d625..7843e40 100644 --- a/src/CCC/BatchManager_CCC.cxx +++ b/src/CCC/BatchManager_CCC.cxx @@ -156,7 +156,7 @@ namespace Batch { // Methode pour le controle des jobs : teste si un job est present en machine - bool BatchManager_CCC::isRunning(const JobId & jobid) + bool BatchManager_CCC::isRunning(const JobId & /*jobid*/) { throw NotYetImplementedException("BatchManager_CCC::isRunning"); } diff --git a/src/Core/BatchManager.cxx b/src/Core/BatchManager.cxx index 10a1e98..3af9e2e 100644 --- a/src/Core/BatchManager.cxx +++ b/src/Core/BatchManager.cxx @@ -84,48 +84,48 @@ namespace Batch { } // Methode pour le controle des jobs : retire un job du gestionnaire - void BatchManager::deleteJob(const JobId & jobid) + void BatchManager::deleteJob(const JobId & /*jobid*/) { throw NotYetImplementedException("Method deleteJob not implemented by Batch Manager \"" + _type + "\""); } // Methode pour le controle des jobs : suspend un job en file d'attente - void BatchManager::holdJob(const JobId & jobid) + void BatchManager::holdJob(const JobId & /*jobid*/) { throw NotYetImplementedException("Method holdJob not implemented by Batch Manager \"" + _type + "\""); } // Methode pour le controle des jobs : relache un job suspendu - void BatchManager::releaseJob(const JobId & jobid) + void BatchManager::releaseJob(const JobId & /*jobid*/) { throw NotYetImplementedException("Method releaseJob not implemented by Batch Manager \"" + _type + "\""); } // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) + void BatchManager::alterJob(const JobId & /*jobid*/, const Parametre & /*param*/, const Environnement & /*env*/) { throw NotYetImplementedException("Method alterJob not implemented by Batch Manager \"" + _type + "\""); } // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager::alterJob(const JobId & jobid, const Parametre & param) + void BatchManager::alterJob(const JobId & /*jobid*/, const Parametre & /*param*/) { throw NotYetImplementedException("Method alterJob not implemented by Batch Manager \"" + _type + "\""); } // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager::alterJob(const JobId & jobid, const Environnement & env) + void BatchManager::alterJob(const JobId & /*jobid*/, const Environnement & /*env*/) { throw NotYetImplementedException("Method alterJob not implemented by Batch Manager \"" + _type + "\""); } // Methode pour le controle des jobs : renvoie l'etat du job - JobInfo BatchManager::queryJob(const JobId & jobid) + JobInfo BatchManager::queryJob(const JobId & /*jobid*/) { throw NotYetImplementedException("Method queryJob not implemented by Batch Manager \"" + _type + "\""); } - const JobId BatchManager::addJob(const Job & job, const string & reference) + const JobId BatchManager::addJob(const Job & /*job*/, const string & reference) { return JobId(this, reference); } @@ -390,7 +390,7 @@ namespace Batch { } } - const Batch::JobId BatchManager::runJob(const Batch::Job & job) + const Batch::JobId BatchManager::runJob(const Batch::Job & /*job*/) { throw NotYetImplementedException("Method runJob not implemented by Batch Manager \"" + _type + "\""); } diff --git a/src/Core/BatchManagerCatalog.hxx b/src/Core/BatchManagerCatalog.hxx index 63b6b21..4e7803d 100644 --- a/src/Core/BatchManagerCatalog.hxx +++ b/src/Core/BatchManagerCatalog.hxx @@ -66,8 +66,8 @@ namespace Batch { private: // Forbid the use of copy constructor and assignment operator - BatchManagerCatalog(const BatchManagerCatalog & orig) {} - void operator=(const BatchManagerCatalog & orig) {} + BatchManagerCatalog(const BatchManagerCatalog &) {} + void operator=(const BatchManagerCatalog &) {} }; diff --git a/src/Core/CommunicationProtocolSH.cxx b/src/Core/CommunicationProtocolSH.cxx index 4f55ac5..2822b9d 100644 --- a/src/Core/CommunicationProtocolSH.cxx +++ b/src/Core/CommunicationProtocolSH.cxx @@ -41,8 +41,8 @@ namespace Batch { } vector CommunicationProtocolSH::getExecCommandArgs(const string & subCommand, - const string & host, - const string & user) const + const string & /*host*/, + const string & /*user*/) const { vector cmd; @@ -60,11 +60,11 @@ namespace Batch { } vector CommunicationProtocolSH::getCopyCommandArgs(const string & sourcePath, - const string & sourceHost, - const string & sourceUser, + const string & /*sourceHost*/, + const string & /*sourceUser*/, const string & destinationPath, - const string & destinationHost, - const string & destinationUser) const + const string & /*destinationHost*/, + const string & /*destinationUser*/) const { vector cmd; cmd.push_back(CP_COMMAND); diff --git a/src/Core/Log.hxx b/src/Core/Log.hxx index 21b89eb..47245dc 100644 --- a/src/Core/Log.hxx +++ b/src/Core/Log.hxx @@ -53,8 +53,8 @@ namespace Batch { static Log & getInstance(); // Forbid the use of copy constructor and assignment operator - Log(const Log & orig) {} - void operator=(const Log & orig) {} + Log(const Log &) {} + void operator=(const Log &) {} std::ofstream _stream; diff --git a/src/Core/MpiImpl.cxx b/src/Core/MpiImpl.cxx index 13650c4..9cb46d4 100644 --- a/src/Core/MpiImpl.cxx +++ b/src/Core/MpiImpl.cxx @@ -58,14 +58,14 @@ string MpiImpl_LAM::rank() return "${LAMRANK}"; } -string MpiImpl_LAM::boot(const string machinefile, const unsigned int nbnodes) +string MpiImpl_LAM::boot(const string machinefile, const unsigned int /*nbnodes*/) { ostringstream oss; oss << "lamboot " << machinefile << endl; return oss.str(); } -string MpiImpl_LAM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute) +string MpiImpl_LAM::run(const string /*machinefile*/, const unsigned int nbproc, const string fileNameToExecute) { ostringstream oss; oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl; @@ -105,7 +105,7 @@ string MpiImpl_MPICH1::rank() return "${MPIRUN_RANK}"; } -string MpiImpl_MPICH1::boot(const string machinefile, const unsigned int nbnodes) +string MpiImpl_MPICH1::boot(const string /*machinefile*/, const unsigned int /*nbnodes*/) { return ""; } @@ -158,7 +158,7 @@ string MpiImpl_MPICH2::boot(const string machinefile, const unsigned int nbnodes return oss.str(); } -string MpiImpl_MPICH2::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute) +string MpiImpl_MPICH2::run(const string /*machinefile*/, const unsigned int nbproc, const string fileNameToExecute) { ostringstream oss; oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl; @@ -198,7 +198,7 @@ string MpiImpl_OPENMPI::rank() return "${OMPI_MCA_ns_nds_vpid}"; } -string MpiImpl_OPENMPI::boot(const string machinefile, const unsigned int nbnodes) +string MpiImpl_OPENMPI::boot(const string /*machinefile*/, const unsigned int /*nbnodes*/) { return ""; } @@ -241,7 +241,7 @@ string MpiImpl_OMPI::rank() return "${OMPI_MCA_ns_nds_vpid}"; } -string MpiImpl_OMPI::boot(const string machinefile, const unsigned int nbnodes) +string MpiImpl_OMPI::boot(const string /*machinefile*/, const unsigned int /*nbnodes*/) { return ""; } @@ -284,12 +284,12 @@ string MpiImpl_SLURM::rank() return "${SLURM_PROCID}"; } -string MpiImpl_SLURM::boot(const string machinefile, const unsigned int nbnodes) +string MpiImpl_SLURM::boot(const string /*machinefile*/, const unsigned int /*nbnodes*/) { return ""; } -string MpiImpl_SLURM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute) +string MpiImpl_SLURM::run(const string /*machinefile*/, const unsigned int /*nbproc*/, const string fileNameToExecute) { ostringstream oss; oss << "srun " << fileNameToExecute << endl; @@ -327,12 +327,12 @@ string MpiImpl_PRUN::rank() return "${RMS_RANK}"; } -string MpiImpl_PRUN::boot(const string machinefile, const unsigned int nbnodes) +string MpiImpl_PRUN::boot(const string /*machinefile*/, const unsigned int /*nbnodes*/) { return ""; } -string MpiImpl_PRUN::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute) +string MpiImpl_PRUN::run(const string /*machinefile*/, const unsigned int nbproc, const string fileNameToExecute) { ostringstream oss; oss << "prun -n " << nbproc << " " << "-p mpi " << fileNameToExecute << endl; diff --git a/src/Core/ParameterTypeMap.hxx b/src/Core/ParameterTypeMap.hxx index 29d1ac7..d2ccf72 100644 --- a/src/Core/ParameterTypeMap.hxx +++ b/src/Core/ParameterTypeMap.hxx @@ -67,8 +67,8 @@ namespace Batch { private: // Forbid the use of copy constructor and assignment operator - ParameterTypeMap(const ParameterTypeMap & orig) {} - void operator=(const ParameterTypeMap & orig) {} + ParameterTypeMap(const ParameterTypeMap &) {} + void operator=(const ParameterTypeMap &) {} }; diff --git a/src/Core/Versatile.cxx b/src/Core/Versatile.cxx index 9828973..ff85ba2 100644 --- a/src/Core/Versatile.cxx +++ b/src/Core/Versatile.cxx @@ -52,9 +52,10 @@ namespace Batch { } Versatile::Versatile(const Versatile & V) - : _discriminator(V._discriminator), - _maxsize(V._maxsize), - _name(V._name) + : list(), + _discriminator(V._discriminator), + _maxsize(V._maxsize), + _name(V._name) { Versatile::const_iterator it; for(it=V.begin(); it!=V.end(); it++) diff --git a/src/Core/Versatile.hxx b/src/Core/Versatile.hxx index d72f8e9..b26fdd1 100644 --- a/src/Core/Versatile.hxx +++ b/src/Core/Versatile.hxx @@ -108,8 +108,8 @@ namespace Batch { private: - // Forbid the use of affectation operator - void operator= (const Versatile & V) {} + // Forbid the use of assignment operator + void operator= (const Versatile &) {} }; diff --git a/src/LSF/BatchManager_LSF.cxx b/src/LSF/BatchManager_LSF.cxx index f543983..646bbca 100644 --- a/src/LSF/BatchManager_LSF.cxx +++ b/src/LSF/BatchManager_LSF.cxx @@ -131,7 +131,7 @@ namespace Batch { // Methode pour le controle des jobs : teste si un job est present en machine - bool BatchManager_LSF::isRunning(const JobId & jobid) + bool BatchManager_LSF::isRunning(const JobId & /*jobid*/) { throw NotYetImplementedException("BatchManager_LSF::isRunning"); } diff --git a/src/Local/BatchManager_Local.cxx b/src/Local/BatchManager_Local.cxx index 6499333..40ba3fe 100644 --- a/src/Local/BatchManager_Local.cxx +++ b/src/Local/BatchManager_Local.cxx @@ -225,7 +225,7 @@ namespace Batch { // On force donc l'état du job à erreur - pour cela on ne donne pas d'Id // au JobId const Batch::JobId - BatchManager_Local::addJob(const Batch::Job & job, const std::string & reference) + BatchManager_Local::addJob(const Batch::Job & /*job*/, const std::string & /*reference*/) { return JobId(this, "undefined"); } diff --git a/src/PBS/BatchManager_PBS.cxx b/src/PBS/BatchManager_PBS.cxx index 72bf971..c3cf644 100644 --- a/src/PBS/BatchManager_PBS.cxx +++ b/src/PBS/BatchManager_PBS.cxx @@ -128,7 +128,7 @@ namespace Batch { } // Methode pour le controle des jobs : teste si un job est present en machine - bool BatchManager_PBS::isRunning(const JobId & jobid) + bool BatchManager_PBS::isRunning(const JobId & /*jobid*/) { throw NotYetImplementedException("BatchManager_PBS::isRunning"); } diff --git a/src/SGE/BatchManager_SGE.cxx b/src/SGE/BatchManager_SGE.cxx index 23ad6df..cfac6d8 100644 --- a/src/SGE/BatchManager_SGE.cxx +++ b/src/SGE/BatchManager_SGE.cxx @@ -147,7 +147,7 @@ namespace Batch { } // Methode pour le controle des jobs : teste si un job est present en machine - bool BatchManager_SGE::isRunning(const JobId & jobid) + bool BatchManager_SGE::isRunning(const JobId & /*jobid*/) { throw NotYetImplementedException("BatchManager_SGE::isRunning"); } diff --git a/src/Vishnu/BatchManager_Vishnu.cxx b/src/Vishnu/BatchManager_Vishnu.cxx index 113e99e..4e93051 100644 --- a/src/Vishnu/BatchManager_Vishnu.cxx +++ b/src/Vishnu/BatchManager_Vishnu.cxx @@ -49,7 +49,7 @@ namespace Batch { BatchManager_Vishnu::BatchManager_Vishnu(const FactBatchManager * parent, const char * host, const char * username, - CommunicationProtocolType protocolType, + CommunicationProtocolType /*protocolType*/, const char * mpiImpl) : // Force SH protocol for Vishnu BatchManager(parent, host, username, SH, mpiImpl) -- 2.39.2