From 13bc4cb24f7ed45272e7f30d54fc05693b8f78b5 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Tue, 24 Jun 2014 00:05:53 +0300 Subject: [PATCH] Added -fvisibility=hidden parameter for gcc. Should help a bit with endless missing DLL_LINKAGE attributes and (according to gcc docs) help a bit with library loading times. --- CMakeLists.txt | 7 ++++++- lib/NetPacks.h | 5 ++--- lib/NetPacksBase.h | 6 +++--- lib/NetPacksLib.cpp | 10 ---------- lib/mapObjects/JsonRandom.h | 28 ++++++++++++++-------------- 5 files changed, 25 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 420bf163c..9a06161a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,9 +100,14 @@ endif() if(CMAKE_COMPILER_IS_GNUCXX OR NOT WIN32) #so far all *nix compilers support such parameters if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CLANG_SPECIFIC_FLAGS "-Wno-mismatched-tags") + set(CLANG_SPECIFIC_FLAGS "-Wno-mismatched-tags") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wuninitialized -Wno-overloaded-virtual ${CLANG_SPECIFIC_FLAGS}") + + if(UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + endif() + endif() if(WIN32) # on Win everything goes into H3 root directory diff --git a/lib/NetPacks.h b/lib/NetPacks.h index 5f8c0d666..ea6cc2c62 100644 --- a/lib/NetPacks.h +++ b/lib/NetPacks.h @@ -1527,7 +1527,7 @@ struct ObstaclesRemoved : public CPackForClient //3014 } }; -struct CatapultAttack : public CPackForClient //3015 +struct DLL_LINKAGE CatapultAttack : public CPackForClient //3015 { struct AttackInfo { @@ -1543,8 +1543,7 @@ struct CatapultAttack : public CPackForClient //3015 } }; - DLL_LINKAGE CatapultAttack(); - DLL_LINKAGE ~CatapultAttack(); + CatapultAttack() {type = 3015;} DLL_LINKAGE void applyGs(CGameState *gs); void applyCl(CClient *cl); diff --git a/lib/NetPacksBase.h b/lib/NetPacksBase.h index aca2fd62d..e365d6b76 100644 --- a/lib/NetPacksBase.h +++ b/lib/NetPacksBase.h @@ -25,7 +25,7 @@ struct ArtSlotInfo; #include "GameConstants.h" -struct CPack +struct DLL_LINKAGE CPack { ui16 type; @@ -37,7 +37,7 @@ struct CPack logNetwork->errorStream() << "CPack serialized... this should not happen!"; } void applyGs(CGameState *gs) { } - virtual std::string toString() const { return boost::str(boost::format("{CPack: type '%d'}") % type); } + DLL_LINKAGE virtual std::string toString() const { return boost::str(boost::format("{CPack: type '%d'}") % type); } }; std::ostream & operator<<(std::ostream & out, const CPack * pack); @@ -197,4 +197,4 @@ struct ArtifactLocation { h & artHolder & slot; } -}; \ No newline at end of file +}; diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 479a9311d..5e86e6b49 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -1495,16 +1495,6 @@ DLL_LINKAGE void ObstaclesRemoved::applyGs( CGameState *gs ) } } -DLL_LINKAGE CatapultAttack::CatapultAttack() -{ - type = 3015; -} - -DLL_LINKAGE CatapultAttack::~CatapultAttack() -{ - -} - DLL_LINKAGE void CatapultAttack::applyGs( CGameState *gs ) { if(gs->curB && gs->curB->siege != CGTownInstance::NONE) //if there is a battle and it's a siege diff --git a/lib/mapObjects/JsonRandom.h b/lib/mapObjects/JsonRandom.h index 6e44da040..80feeff20 100644 --- a/lib/mapObjects/JsonRandom.h +++ b/lib/mapObjects/JsonRandom.h @@ -23,28 +23,28 @@ class CStackBasicDescriptor; namespace JsonRandom { - struct RandomStackInfo + struct DLL_LINKAGE RandomStackInfo { std::vector allowedCreatures; si32 minAmount; si32 maxAmount; }; - si32 loadValue(const JsonNode & value, CRandomGenerator & rng, si32 defaultValue = 0); - TResources loadResources(const JsonNode & value, CRandomGenerator & rng); - std::vector loadPrimary(const JsonNode & value, CRandomGenerator & rng); - std::map loadSecondary(const JsonNode & value, CRandomGenerator & rng); + DLL_LINKAGE si32 loadValue(const JsonNode & value, CRandomGenerator & rng, si32 defaultValue = 0); + DLL_LINKAGE TResources loadResources(const JsonNode & value, CRandomGenerator & rng); + DLL_LINKAGE std::vector loadPrimary(const JsonNode & value, CRandomGenerator & rng); + DLL_LINKAGE std::map loadSecondary(const JsonNode & value, CRandomGenerator & rng); - ArtifactID loadArtifact(const JsonNode & value, CRandomGenerator & rng); - std::vector loadArtifacts(const JsonNode & value, CRandomGenerator & rng); + DLL_LINKAGE ArtifactID loadArtifact(const JsonNode & value, CRandomGenerator & rng); + DLL_LINKAGE std::vector loadArtifacts(const JsonNode & value, CRandomGenerator & rng); - SpellID loadSpell(const JsonNode & value, CRandomGenerator & rng, std::vector spells); - std::vector loadSpells(const JsonNode & value, CRandomGenerator & rng, std::vector spells); + DLL_LINKAGE SpellID loadSpell(const JsonNode & value, CRandomGenerator & rng, std::vector spells); + DLL_LINKAGE std::vector loadSpells(const JsonNode & value, CRandomGenerator & rng, std::vector spells); - CStackBasicDescriptor loadCreature(const JsonNode & value, CRandomGenerator & rng); - std::vector loadCreatures(const JsonNode & value, CRandomGenerator & rng); - std::vector evaluateCreatures(const JsonNode & value); + DLL_LINKAGE CStackBasicDescriptor loadCreature(const JsonNode & value, CRandomGenerator & rng); + DLL_LINKAGE std::vector loadCreatures(const JsonNode & value, CRandomGenerator & rng); + DLL_LINKAGE std::vector evaluateCreatures(const JsonNode & value); - std::vector loadBonuses(const JsonNode & value); - std::vector loadComponents(const JsonNode & value); + DLL_LINKAGE std::vector loadBonuses(const JsonNode & value); + DLL_LINKAGE std::vector loadComponents(const JsonNode & value); }