Add compat.h and constants.cpp and centralize conditional constexpr.