2
0
Эх сурвалжийг харах

Renamed UNUSED -> MAYBE_UNUSED macro to match c++17 attribute name

Ivan Savenko 2 жил өмнө
parent
commit
fb6b3c31e8

+ 9 - 8
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<typename T, size_t N> 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

+ 1 - 1
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<CHeroWindow>(buf);

+ 1 - 1
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);

+ 1 - 1
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

+ 1 - 1
lib/CStack.cpp

@@ -307,7 +307,7 @@ std::vector<BattleHex> CStack::meleeAttackHexes(const battle::Unit * attacker, c
 			res.push_back(otherDefenderPos);
 		}
 	}
-	UNUSED(mask);
+	MAYBE_UNUSED(mask);
 
 	return res;
 }

+ 4 - 4
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);

+ 1 - 1
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());
 	}

+ 1 - 0
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());
 	}