forgottenserver
forgottenserver copied to clipboard
Top-level constexprs in header files should be inline
When we declare a static constexpr, it means that the value will be present in each compilation unit i.e. each object generated with a cpp file. That means, if a static constexpr is declared in a header file, that every cpp file that includes that header (even indirectly) will have it's own copy of that value.
It can be seen that, if static is removed, the compiler will detect the name clash (which is avoided by static).
These top-level constexprs present in header files should be inline, such that the declarations are merged when the executable is linked and only 1 copy will be present.
Tip: search using regex for ^static constexpr in src/*.h