我将#ifndef..#define..#endif 添加到我的项目文件中,但编译器失败.一旦我删除它或在定义中放置任何其他名称,它就可以正常编译.可能是什么问题呢?
I added #ifndef..#define..#endif to a file of my project and the compiler fails. As soon as I remove it or put any other name in the define it compiles fine. What could be the problem?
听起来文件已经声明了,但我不知道在哪里.我可以删除它,但我真的很想知道为什么会这样.
Sounds like the file is already declared, but I do not know where. I'm fine just removing it, but I really want to know why this is happening.
error: expected class-name before ‘{’ token
error: ‘QDesignerFormEditorInterface’ has not been declared
还有一些其他错误.
我实际上使用的是 Qt 中的一个示例,自定义小部件插件示例".
I am actually using an example from Qt, "Custom Widget Plugin Example".
不同之处在于我将自己的类用于自定义小部件(.h、.cpp 和 .ui 文件).
The difference is I am using my own class for the custom widget (.h, .cpp and .ui file).
它可能与包含 2 个包含的文件有关,尽管示例就是这样做的.
It might have to do with the file that has 2 includes, though that is how the example did it.
此宏是否用作 包含保护?如果是这样,听起来您是在复制其他地方使用的名称.当人们不考虑包含保护必须具有的范围时,这是一个常见问题——您应该在其中包含更多信息,而不仅仅是文件名.
Is this macro used as an include guard? If so, it sounds like you're duplicating a name used elsewhere. This is a common problem when people don't think about the scope an include guard must have—you should include much more information in it than just the file name.
包括后卫进球:
错误的包含保护名称(对于文件config.h"):
Bad include guard names (for file "config.h"):
CONFIG_H
好的包含保护名称(对于文件config.h"):
Good include guard names (for file "config.h"):
PATE_20091116_142045
<姓氏>_<日期>_<时间>
这篇关于添加包含保护会破坏构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!