How do you indent preprocessor statements?

前端 未结 5 1204
春和景丽
春和景丽 2021-02-03 23:21

When there are many preprocessor statements and many #ifdef cascades, it\'s hard to get an overview since normally they are not indented. e.g.

#ifdef __WIN32__
#         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-04 00:10

    "All that said, there's no rule that you can't indent preprocessor checks if it makes the code more readable."

    No, but in a world where style is controlled and the code is adjusted to match it would be nice to enable the style to indent #if statements like if statements.

    While #if might technically be a different language it is part of the C/C++ specification and as it is not a letter for letter match of any current keywords there is no reason that #ifs can not be accommodated for in the styling.

提交回复
热议问题