Indenting #defines

后端 未结 9 2098
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 00:34

I know that #defines, etc. are normally never indented. Why?

I\'m working in some code at the moment which has a horrible mixture of #define

9条回答
  •  误落风尘
    2020-11-30 00:42

    For the example you've given it may be appropriate to use indentation to make it clearer, seeing as you have such a complex structure of nested directives.

    Personally I think it is useful to keep them not indented most of the time, because these directives operate separately from the rest of your code. Directives such as #ifdef are handled by the pre-processor, before the compiler ever sees your code, so a block of code after an #ifdef directive may not even be compiled.

    Keeping directives visually separated from the rest of your code is more important when they are interspersed with code (rather than a dedicated block of directives, as in the example you give).

提交回复
热议问题