为什么你的编译器应该警告你。
假设你的头文件是这样的:
#ifndef X
#define X
// STUFF
// The next line does not contain an EOL marker (can happen)
#endif
现在你从源代码中包含这个
#include "plop.h"
class X
{
}
当编译器在技术上包含该文件时,扩展的源代码应如下所示
#define X
// STUFF
// The next line does not contain an EOL marker (can happen)
#endif class X
{
}
Most modern compiler take into account his could happen and stick an extra EOL token on included files to prevent this from happening (technically not allowed but I can't think of a situation where it would cause a problem).
The problem is that some older compilers don't provide this extra token (more standards compliant) but as a result you can potentially end up compiling the above code (as a result they tend to warn you about two things 1) missing EOL in source files and 2) things after the #endif