I'm using clang-format with the following IntegerLiteralSeparator settings:
IntegerLiteralSeparator:
Binary: 4
Decimal: 3
Hex: 2
When formatting code like this:
#if __cpp_lib_smart_ptr_owner_equality >= 202306L
clang-format transforms it into:
#if __cpp_lib_smart_ptr_owner_equality >= 202'306L
which causes a compilation error because the preprocessor does not accept digit separators ' in numeric literals inside directives.
I’m aware that since C++20, there is an alternative to test feature macros using:
#if __has_cpp_attribute(__cpp_lib_smart_ptr_owner_equality)
However, it would still be useful to have either:
- an option to disable
IntegerLiteralSeparator only inside preprocessor directives, or
- for the behavior to be changed so that
IntegerLiteralSeparator is not applied at all to preprocessor lines or specific preprocessor instructions such as #if
This suggestion is intended to make formatting smoother and avoid breaking code when numeric literals appear in preprocessor conditionals