Why it's valid to include a header file twice in c++?

后端 未结 7 882
迷失自我
迷失自我 2021-02-09 17:25
#include \"DLLDefines.h\"
#include \"DLLDefines.h\"

The above actually passed compilation, but why?

7条回答
  •  孤城傲影
    2021-02-09 17:56

    Probably you have some #define in DLLDefines.h around your code that prevents it from being included twice.

    #ifndef DLLDEFINES_H
    #define DLLDEFINES_H
    // your code
    #endif
    

提交回复
热议问题