How do you indent preprocessor statements?

前端 未结 5 1106
春和景丽
春和景丽 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:07

    Just because preprocessing directives are "normally" not indented is not a good reason not to indent them:

    #ifdef __WIN32__
        #include 
    #else
        #include <..>
        #ifdef SOMEOTHER
            stmts
        #endif
        maybe stmts
    #endif
    

    If you frequently have multiple levels of nesting of preprocessing directives, you should rework them to make them simpler.

提交回复
热议问题