Skip to content

Commit b8fa42b

Browse files
committed
fix(debug): Replace nullptr with false in DEBUG_ASSERTCRASH macros
Fix all instances of DEBUG_ASSERTCRASH(nullptr, ...) that cause compilation errors in MinGW-w64 debug builds due to implicit nullptr-to-bool conversion. Changes: - PlayerTemplate.cpp: 1 instance fixed - ChallengeGenerals.cpp: 1 instance fixed - LoadScreen.cpp: 2 instances fixed Total: 4 instances fixed across GeneralsMD codebase The DEBUG_ASSERTCRASH macro expects a boolean condition as its first argument. Using nullptr (std::nullptr_t) requires direct-initialization to convert to bool, which MinGW treats as an error with -fpermissive. These instances were introduced by commit f891c5f ("refactor: Modernize NULL to nullptr") which converted NULL to nullptr throughout the codebase. However, DEBUG_ASSERTCRASH(NULL, ...) was semantically DEBUG_ASSERTCRASH(0, ...) meaning "unconditional crash", which is more explicitly written as DEBUG_ASSERTCRASH(false, ...). Error resolved: error: converting to 'bool' from 'std::nullptr_t' requires direct-initialization [-fpermissive] VC6 compatibility: The 'false' keyword is fully supported in C++98 and VC6, making this change safe for all target compilers. Affects: GeneralsMD debug builds only
1 parent f784923 commit b8fa42b

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

GeneralsMD/Code/GameEngine/Source/Common/RTS/PlayerTemplate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ Int PlayerTemplateStore::getTemplateNumByName(AsciiString name) const
294294
if (m_playerTemplates[num].getName().compareNoCase(name.str()) == 0)
295295
return num;
296296
}
297-
DEBUG_ASSERTCRASH(nullptr, ("Template doesn't exist for given name"));
297+
DEBUG_ASSERTCRASH(false, ("Template doesn't exist for given name"));
298298
return -1;
299299
}
300300

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const GeneralPersona* ChallengeGenerals::getPlayerGeneralByCampaignName( AsciiSt
133133
if (campaignName.compareNoCase( name.str() ) == 0)
134134
return &m_position[i];
135135
}
136-
DEBUG_ASSERTCRASH(nullptr, ("Can't find General by Campaign Name"));
136+
DEBUG_ASSERTCRASH(false, ("Can't find General by Campaign Name"));
137137
return nullptr;
138138
}
139139

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ void MultiPlayerLoadScreen::init( GameInfo *game )
13081308
else if (pt->getName() == "FactionChina")
13091309
portrait = TheMappedImageCollection->findImageByName("SNFactionLogoLg_China");
13101310
else
1311-
DEBUG_ASSERTCRASH(nullptr, ("Unexpected player template"));
1311+
DEBUG_ASSERTCRASH(false, ("Unexpected player template"));
13121312

13131313
localName = pt->getDisplayName();
13141314
}
@@ -1579,7 +1579,7 @@ GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
15791579
else if (pt->getName() == "FactionChina")
15801580
portrait = TheMappedImageCollection->findImageByName("SNFactionLogo144_China");
15811581
else
1582-
DEBUG_ASSERTCRASH(nullptr, ("Unexpected player template"));
1582+
DEBUG_ASSERTCRASH(false, ("Unexpected player template"));
15831583

15841584
localName = pt->getDisplayName();
15851585
}

0 commit comments

Comments
 (0)