diff --git a/Global.h b/Global.h index e3de881da..456363444 100644 --- a/Global.h +++ b/Global.h @@ -80,13 +80,13 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); # endif #else # error "VCMI supports only Windows, OSX, Linux and Android targets" -#endif - -// Each compiler uses own way to supress fall through warning. Try to find it. -// TODO: replace with c++17 [[fallthrough]] -#ifdef __has_cpp_attribute -# if __has_cpp_attribute(fallthrough) -# define FALLTHROUGH [[fallthrough]]; +#endif + +// Each compiler uses own way to supress fall through warning. Try to find it. +// TODO: replace with c++17 [[fallthrough]] +#ifdef __has_cpp_attribute +# if __has_cpp_attribute(fallthrough) +# define FALLTHROUGH [[fallthrough]]; # elif __has_cpp_attribute(gnu::fallthrough) # define FALLTHROUGH [[gnu::fallthrough]]; # elif __has_cpp_attribute(clang::fallthrough) @@ -263,7 +263,8 @@ template char (&_ArrayCountObj(const T (&)[N]))[N]; #define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr))) // should be used for variables that becomes unused in release builds (e.g. only used for assert checks) -#define UNUSED(VAR) ((void)VAR) +// TODO: replace with c++17 [[maybe_unused]] +#define MAYBE_UNUSED(VAR) ((void)VAR) // old iOS SDKs compatibility #ifdef VCMI_IOS diff --git a/client/windows/CHeroWindow.cpp b/client/windows/CHeroWindow.cpp index 82f0627aa..3d01e3d94 100644 --- a/client/windows/CHeroWindow.cpp +++ b/client/windows/CHeroWindow.cpp @@ -78,7 +78,7 @@ void CHeroSwitcher::clickLeft(tribool down, bool previousState) #if 0 owner->update(hero, true); #else - UNUSED(owner); + MAYBE_UNUSED(owner); const CGHeroInstance * buf = hero; GH.popInts(1); GH.pushIntT(buf); diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index d75b0f7f3..cb56705a7 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -507,7 +507,7 @@ void CCreatureSet::joinStack(SlotID slot, CStackInstance * stack) const CCreature *c = getCreature(slot); assert(c == stack->type); assert(c); - UNUSED(c); + MAYBE_UNUSED(c); //TODO move stuff changeStackCount(slot, stack->count); diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 90c86c983..f069c8e8b 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -1768,7 +1768,7 @@ void CGameState::initTowns() for(auto building : vti->builtBuildings) { assert(vti->town->buildings.at(building) != nullptr); - UNUSED(building); + MAYBE_UNUSED(building); } //town events diff --git a/lib/CStack.cpp b/lib/CStack.cpp index fb28549b8..682ed2b09 100644 --- a/lib/CStack.cpp +++ b/lib/CStack.cpp @@ -307,7 +307,7 @@ std::vector CStack::meleeAttackHexes(const battle::Unit * attacker, c res.push_back(otherDefenderPos); } } - UNUSED(mask); + MAYBE_UNUSED(mask); return res; } diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 1b1b84a37..646a7c25c 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -731,7 +731,7 @@ DLL_LINKAGE void NewObject::applyGs(CGameState *gs) const int3 previousXAxisTile = int3(pos.x - 1, pos.y, pos.z); assert(gs->isInTheMap(previousXAxisTile) && (testObject.visitablePos() == previousXAxisTile)); - UNUSED(previousXAxisTile); + MAYBE_UNUSED(previousXAxisTile); } else { @@ -957,7 +957,7 @@ DLL_LINKAGE void RebalanceStacks::applyGs(CGameState * gs) if(const CCreature *c = dst.army->getCreature(dst.slot)) //stack at dest -> merge { assert(c == srcType); - UNUSED(c); + MAYBE_UNUSED(c); auto alHere = ArtifactLocation (src.getStack(), ArtifactPosition::CREATURE_SLOT); auto alDest = ArtifactLocation (dst.getStack(), ArtifactPosition::CREATURE_SLOT); auto artHere = alHere.getArt(); @@ -1008,7 +1008,7 @@ DLL_LINKAGE void RebalanceStacks::applyGs(CGameState * gs) if(const CCreature *c = dst.army->getCreature(dst.slot)) //stack at dest -> rebalance { assert(c == srcType); - UNUSED(c); + MAYBE_UNUSED(c); if (stackExp) { ui64 totalExp = srcCount * src.army->getStackExperience(src.slot) + dst.army->getStackCount(dst.slot) * dst.army->getStackExperience(dst.slot); @@ -1177,7 +1177,7 @@ DLL_LINKAGE void AssembledArtifact::applyGs(CGameState *gs) assert(transformedArt); bool combineEquipped = !ArtifactUtils::isSlotBackpack(al.slot); assert(vstd::contains(transformedArt->assemblyPossibilities(artSet, combineEquipped), builtArt)); - UNUSED(transformedArt); + MAYBE_UNUSED(transformedArt); auto combinedArt = new CCombinedArtifactInstance(builtArt); gs->map->addNewArtifactInstance(combinedArt); diff --git a/lib/filesystem/CInputStream.h b/lib/filesystem/CInputStream.h index e5f2c0839..856ab2076 100644 --- a/lib/filesystem/CInputStream.h +++ b/lib/filesystem/CInputStream.h @@ -45,7 +45,7 @@ public: seek(0); auto readSize = read(data.get(), getSize()); assert(readSize == getSize()); - UNUSED(readSize); + MAYBE_UNUSED(readSize); return std::make_pair(std::move(data), getSize()); } diff --git a/lib/rmg/WaterProxy.cpp b/lib/rmg/WaterProxy.cpp index 84f62cf93..d61913a63 100644 --- a/lib/rmg/WaterProxy.cpp +++ b/lib/rmg/WaterProxy.cpp @@ -42,6 +42,7 @@ void WaterProxy::process() //check terrain type for(auto & t : zone.area().getTilesVector()) { + MAYBE_UNUSED(t); assert(map.isOnMap(t)); assert(map.map().getTile(t).terType->id == zone.getTerrainType()); }