Advantages of conditional-preprocessor over conditional statements

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

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

5条回答
  •  感动是毒
    2021-01-12 07:43

    The use of the preprocessor directives in this case is not entirely useful. But the use of these preprocessor directives is useful in many other cases.

    These preprocessor directives can be used for conditional compilation. e.g. If some program has to be developed for multiple platforms then platform-specific constants can be given values. Changing these values compilation specific to the platform can be done while the whole code can be maintained as one big entity.

    These are also useful while debugging. Test units can be compiled into the code and ran by using these conditional compilations while debugging and they can be stopped from compiling using these.

提交回复
热议问题