From f4614658cf06d641e4e5cbb51bd1f7224e5cadc3 Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 29 May 2017 19:46:11 +0100 Subject: [PATCH] Fix -Wundefined-var-template warning (#963) This avoids specializing CSingleton::m_instance for each type, and instead just defines it once in the header. This is allowed by the standard, multiple definitions are merged in the same way that inline functions are. --- src/app/app.cpp | 3 --- src/app/input.cpp | 3 --- src/app/pathman.cpp | 2 -- src/common/config_file.cpp | 3 --- src/common/logger.cpp | 4 ---- src/common/settings.cpp | 2 -- src/common/singleton.h | 1 + src/graphics/engine/engine.cpp | 2 -- src/level/robotmain.cpp | 3 --- src/object/object_manager.cpp | 4 ---- 10 files changed, 1 insertion(+), 26 deletions(-) diff --git a/src/app/app.cpp b/src/app/app.cpp index f019ccc0..c780e20e 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -61,9 +61,6 @@ #include #include - -template<> CApplication* CSingleton::m_instance = nullptr; - char CApplication::m_languageLocale[] = { 0 }; diff --git a/src/app/input.cpp b/src/app/input.cpp index 87cedf34..142a4554 100644 --- a/src/app/input.cpp +++ b/src/app/input.cpp @@ -32,9 +32,6 @@ #include #include - -template<> CInput* CSingleton::m_instance = nullptr; - CInput::CInput() : m_keyPresses() { diff --git a/src/app/pathman.cpp b/src/app/pathman.cpp index a3848280..c5f7e50a 100644 --- a/src/app/pathman.cpp +++ b/src/app/pathman.cpp @@ -37,8 +37,6 @@ #include #include -template<> CPathManager* CSingleton::m_instance = nullptr; - CPathManager::CPathManager(CSystemUtils* systemUtils) : m_systemUtils(systemUtils) { diff --git a/src/common/config_file.cpp b/src/common/config_file.cpp index 6148eaec..94496ca1 100644 --- a/src/common/config_file.cpp +++ b/src/common/config_file.cpp @@ -34,9 +34,6 @@ #include #include - -template<> CConfigFile* CSingleton::m_instance = nullptr; - namespace bp = boost::property_tree; CConfigFile::CConfigFile() diff --git a/src/common/logger.cpp b/src/common/logger.cpp index b5e5b9cb..ed9bdb5d 100644 --- a/src/common/logger.cpp +++ b/src/common/logger.cpp @@ -22,10 +22,6 @@ #include - -template<> CLogger* CSingleton::m_instance = nullptr; - - CLogger::CLogger() { #if DEV_BUILD diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 4519b079..8ebd55cc 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -32,8 +32,6 @@ #include "sound/sound.h" -template<> CSettings* CSingleton::m_instance = nullptr; - CSettings::CSettings() { m_tooltips = true; diff --git a/src/common/singleton.h b/src/common/singleton.h index 005f5243..254fc23d 100644 --- a/src/common/singleton.h +++ b/src/common/singleton.h @@ -73,3 +73,4 @@ private: CSingleton(const CSingleton &) = delete; }; +template T* CSingleton::m_instance = nullptr; diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 943491b6..0c80c308 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -64,8 +64,6 @@ #include #include -template<> Gfx::CEngine* CSingleton::m_instance = nullptr; - // Graphics module namespace namespace Gfx { diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index 6159652e..5f932cbc 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -125,9 +125,6 @@ const Gfx::Color COLOR_REF_ALIEN = Gfx::Color(135.0f/256.0f, 170.0f/256.0f, 13. const Gfx::Color COLOR_REF_GREEN = Gfx::Color(135.0f/256.0f, 170.0f/256.0f, 13.0f/256.0f); // green const Gfx::Color COLOR_REF_WATER = Gfx::Color( 25.0f/256.0f, 255.0f/256.0f, 240.0f/256.0f); // cyan - -template<> CRobotMain* CSingleton::m_instance = nullptr; - //! Constructor of robot application CRobotMain::CRobotMain() { diff --git a/src/object/object_manager.cpp b/src/object/object_manager.cpp index a33a89fc..e8323a5e 100644 --- a/src/object/object_manager.cpp +++ b/src/object/object_manager.cpp @@ -36,10 +36,6 @@ #include - -template<> CObjectManager* CSingleton::m_instance = nullptr; - - CObjectManager::CObjectManager(Gfx::CEngine* engine, Gfx::CTerrain* terrain, Gfx::COldModelManager* oldModelManager,