Right. clang-format does this automatically. In <caeokux8w9smjqdgoalcgf9vxe+p7x3lahqjm8hg-hyzj3xy...@mail.gmail.com> "Re: [DISCUSS][C++] Indent #if (preprocessor directives)" on Wed, 28 Aug 2024 23:24:17 +0800, Gang Wu <ust...@gmail.com> wrote:
> I believe this is already done by clang-format [1] > > [1] > https://github.com/apache/arrow/pull/43798/files#diff-1026e0038b722990204a42bed8a6f7c0ec2302aa79e3fad1959d62ba968edfa2 > > Best, > Gang > > On Wed, Aug 28, 2024 at 4:35 PM Antoine Pitrou <anto...@python.org> wrote: > >> >> Is there a way to ensure this is done automatically? >> >> Regards >> >> Antoine. >> >> >> >> On Wed, 28 Aug 2024 10:05:45 +0900 (JST) >> Sutou Kouhei <k...@clear-code.com> wrote: >> > Hi, >> > >> > How about indenting preprocessor directives for readability? >> > >> > Issue: https://github.com/apache/arrow/issues/43796 >> > PR: https://github.com/apache/arrow/pull/43798 >> > >> > For example: >> > >> > Before: >> > >> > ---- >> > #ifndef NDEBUG >> > #include "arrow/acero/options_internal.h" >> > #endif >> > ---- >> > >> > After: >> > >> > ---- >> > #ifndef NDEBUG >> > # include "arrow/acero/options_internal.h" >> > #endif >> > ---- >> > >> > >> > FYI: Google C++ style guide (our coding style is based on >> > it) doesn't require indent in preprocessor directives nor >> > deny it: >> > >> > >> https://google.github.io/styleguide/cppguide.html#Preprocessor_Directives >> > >> > ---- >> > // Good - directives at beginning of line >> > if (lopsided_score) { >> > #if DISASTER_PENDING // Correct -- Starts at beginning of line >> > DropEverything(); >> > # if NOTIFY // OK but not required -- Spaces after # >> > NotifyClient(); >> > # endif >> > #endif >> > BackToNormal(); >> > } >> > ---- >> > >> > >> > Thanks, >> >> >> >>