Skip to content

Rename unexpected to UNEXPECTED to prevent clashing with std::unexpected - #314

Open
mikomikotaishi wants to merge 2 commits into
thpatch:masterfrom
mikomikotaishi:chore/rename-unexpected
Open

Rename unexpected to UNEXPECTED to prevent clashing with std::unexpected#314
mikomikotaishi wants to merge 2 commits into
thpatch:masterfrom
mikomikotaishi:chore/rename-unexpected

Conversation

@mikomikotaishi

@mikomikotaishi mikomikotaishi commented Aug 24, 2026

Copy link
Copy Markdown

This PR renames the unexpected macro to condition_unlikely UNEXPECTED. Because C++23 reintroduces the name std::unexpected<E>, this change is needed to remove the possibility of clashing with the standard on later versions. condition_unlikely seems like a more reasonable name, because rather than implying that it should never be expected, it indicates what the hot paths ([[likely]]/[[unlikely]] attributes) are.

CXXFLAGS += -D_GLIBCXX_USE_DEPRECATED=0 was done originally to eliminate the deprecated std::unexpected() (deprecated in C++11 and removed in C++17). Because the macro has been renamed, this is no longer needed.

It was pointed out that the codebase cannot move forward to C++23 (until dropping support for Windows XP or changing the build system). At the very least, this change serves as future-proofing and allows the Makefile to be simplified by dropping the disabled GLIBCXX_USE_DEPRECATED option.

@mikomikotaishi
mikomikotaishi force-pushed the chore/rename-unexpected branch 3 times, most recently from d9da8ba to 666b1c1 Compare August 24, 2026 22:22
@mikomikotaishi mikomikotaishi changed the title Rename unexpected to case_unexpected to prevent clashing with std Rename unexpected to condition_unlikely to prevent clashing with std::unexpected Aug 24, 2026
@mikomikotaishi mikomikotaishi changed the title Rename unexpected to condition_unlikely to prevent clashing with std::unexpected Rename unexpected to UNEXPECTED to prevent clashing with std::unexpected Sep 10, 2026
@mikomikotaishi
mikomikotaishi force-pushed the chore/rename-unexpected branch 3 times, most recently from 5489fd0 to 54b5464 Compare September 10, 2026 01:04
@mikomikotaishi
mikomikotaishi force-pushed the chore/rename-unexpected branch 2 times, most recently from de82872 to 5b071ac Compare September 10, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant