使用前處理器進行註釋

使用前處理器指令 #if 0#endif 也可以註釋掉大塊程式碼。當程式碼包含否則不會巢狀的多行註釋時,這很有用。

#if 0 /* Starts the "comment", anything from here on is removed by preprocessor */ 

/* A large amount of code with multi-line comments */  
int foo()
{
    /* lots of code */
    ...

    /* ... some comment describing the if statement ... */
    if (someTest) {
        /* some more comments */
        return 1;
    }

    return 0;
}

#endif /* 0 */

/* code from here on is "uncommented" (included in compiled executable) */
...