Advantages of conditional-preprocessor over conditional statements

后端 未结 5 2055
遇见更好的自我
遇见更好的自我 2021-01-12 07:30

I have never worked with #if, #ifdef, #ifndef, #else, #elif and #endif

5条回答
  •  逝去的感伤
    2021-01-12 07:56

    Conditional compilation means ifdef-ed out code is never actually in the final linked application. Just using language conditionals means both branches are in the final code making it bigger and potentially harder to test etc.

    Use #ifdef etc when you know at compile time what is required. Language conditionals are used when you don't know what you need until runtime.

提交回复
热议问题