Skip to content

Replace static constexpr with inline constexpr in headers (Fixes #4063) - #5083

Open
mouragst wants to merge 1 commit into
otland:masterfrom
mouragst:fix/replace-static-constexpr-with-inline
Open

Replace static constexpr with inline constexpr in headers (Fixes #4063)#5083
mouragst wants to merge 1 commit into
otland:masterfrom
mouragst:fix/replace-static-constexpr-with-inline

Conversation

@mouragst

@mouragst mouragst commented Apr 9, 2026

Copy link
Copy Markdown

This PR replaces all 53 occurrences of static constexpr with inline constexpr in header files.

Fixes #4063

As described in #4063, when static constexpr is declared in a header file, every compilation unit (cpp file) that includes that header gets its own copy of that value. Using inline constexpr ensures the declarations are merged during linking and only one copy exists in the final executable, reducing binary size and avoiding potential ODR violations.

Replaced static constexpr with inline constexpr in the following files:

  • connection.h (2 changes)
  • const.h (5 changes)
  • definitions.h (8 changes)
  • creature.h (5 changes)
  • game.h (14 changes)
  • map.h (6 changes)
  • monsters.h (2 changes)
  • player.h (4 changes)
  • party.h (2 changes)
  • scheduler.h (1 change)

Total: 53 occurrences across 10 header files

Replaces all 53 occurrences of 'static constexpr' with 'inline constexpr'
in header files to avoid duplicate symbols in each compilation unit.

Fixes otland#4063

When static constexpr is declared in a header file, every cpp file that
includes that header gets its own copy of that value. Using 'inline'
ensures the declarations are merged during linking and only one copy
exists in the final executable.

Affected files:
- connection.h (2 changes)
- const.h (5 changes)
- definitions.h (8 changes)
- creature.h (5 changes)
- game.h (14 changes)
- map.h (6 changes)
- monsters.h (2 changes)
- player.h (4 changes)
- party.h (2 changes)
- scheduler.h (1 change)
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.

Top-level constexprs in header files should be inline

1 participant