Indenting preprocessor directives with clang-format

As of version 6.0, the option IndentPPDirectives can be used. Usage is described in this review.

Using IndentPPDirectives: None results in:

#if FOO
#if BAR
#include <foo>
#endif
#endif

While IndentPPDirectives: AfterHash gives:

#if FOO
#  if BAR
#    include <foo>
#  endif
#endif

Edit: see @Gabriel Staples’ answer for details on the BeforeHash option introduced in clang-format version 9.

Leave a Comment

tech