C++20: Add some endian sanity checks to compat/assumptions.h and compat/endian.h

Summary

In this commit, we leverage the recent upgrade of the codebase to C++20 so as to add some endian-related compile-time checks:

  • In compat/endian.h: We now do a static_assert that the build-system defined WORDS_BIGENDIAN agrees with std::endian::native.
  • In compat/assumptions.h: We now enforce that the target architecture is either big or little endian and not some esoteric mixed or non-endianned platform (this assumption was already baked-in to the codebase, we just make it explicit now). See: https://en.cppreference.com/w/cpp/types/endian.html

Test Plan

None. This is a pure static-check nit commit. If CI is green and everything compiles, everything is ok.

Edited by Calin Culianu

Merge request reports

Loading