Skip to content

Draft: clang-tidy: Add check cppcoreguidelines-macro-usage

Add and apply clang-tidy check cppcoreguidelines-macro-usage.

This check enforces the rule of declaring constants and macros with the constexpr specifier instead of #define, allowing better type safety.

  • Convert all constants to constexpr, including the ones defined with #define and static const.
  • Convert macros to constexpr.
  • Convert logging macros to variadic templates [see ES.34 and this snippet example].
    • Use the std::source_location C++20 library to replace NS_LOG() macros with template functions.
    • Use #ifdef, if constexpr or std::enable_if to merge enabled and disabled logging into one unified function, instead of two files.
Edited by Eduardo Almeida

Merge request reports