Why no warning with “#if X” when X undefined?

后端 未结 8 918
孤独总比滥情好
孤独总比滥情好 2021-02-18 13:06

I occasionally write code something like this:

// file1.cpp
#define DO_THIS 1

#if DO_THIS
    // stuff
#endif

During the code development I ma

8条回答
  •  再見小時候
    2021-02-18 13:23

    The compiler didn't generate a warning because this is a preprocessor directive. It's evaluated and resolved before the compiler sees it.

提交回复
热议问题