missing ';' before 'namesapce'错误的解决
作者:朱金灿
来源:http://blog.csdn.net/clever101
上午开发时出现一个编译错误:missing ';' before 'namesapce',我仔细检查了出错的那句代码,感觉任何没有问题。删掉再重新输入也依然出现这个问题。上网查了下资料,找到了答案:
This can happenwhen one include file has an error (or missing semicolon) at the end of thefile and that file is included immediately before another. The error that isgenerated indicates that there is a problem in the second include file ratherthan the first. So as a starting point, make sure that, if you have a filethat's included before Time.h, that is doesn't have any errors in it.
Pasting thecontent of your .h and .cpp files would certainly be helpful rather than justthe error message.
上面是说某个包含的头文件有一个错误(可能是缺少一个分号)。看到这里,我想到刚刚新建的一个类的头文件声明是不是缺少分号呢?一去检查,发现果然缺少分号。该错误的诡异之处在于编译器并不把错误提示在缺少分号的那个头文件,而是其它头文件,结果就是导致了让人找了很久也百思不得其解。我的编译环境是VS 2005+sp1, Win XP + sp3。
参考文献:
1. ErrorC2143 (missing ; before namespace) in MS VC include
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步