Use of null statement in C

前端 未结 12 1941
挽巷
挽巷 2020-11-29 09:12

What are typical uses of null statement

;

in C ?

I know that it is basically used to skip expression where it is expected

12条回答
  •  臣服心动
    2020-11-29 10:02

    It's typically the side-effect of a code block that was stripped by the preprocessor, like

    #if DEBUG
        #define ASSERT(_x) Assert(_x)
    #else
        #define ASSERT(_x)
    #endif
    
    
    ASSERT(test);    // Results in null statement in non-debug builds
    

    That, or in loops where your condition already contains whatever needs to be done in each iteration.

提交回复
热议问题