error C2143: syntax error : missing ';' before '*....

error   C2143:   syntax   error   :   missing   ';'   before   '*....
 error   C2501:   'CMyDoc'   :   missing   storage-class   or   type   specifiers   
 error   C2501:   'GetDocument'   :   missing   storage-class   or   type   specifiers  

在任何cpp文件的开头都按这样的顺序Include:   
  
  注意,Doc的头文件一定要在最前面。这样你的CDemoView和CMyView也可以共享一个CDemoDoc。  
  一般在Cpp中包含文件是要注意类的包含关系,被包含的类定义应该在前面。如果实在有冲突,可以在一个类的头文件中加:class   CXXXDoc;之类的空定义。这样定义过的头文件中可以用CXXXDoc申明指针,但是不能申明实际对象。

 

from: http://www.cppblog.com/ashura/archive/2007/04/15/21968.html 

C:\Users\Lenovo\Desktop\lj.c(19) : error C2143: syntax error : missing ';' before 'type' C:\Users\Lenovo\Desktop\lj.c(19) : error C2143: syntax error : missing ';' before 'type' C:\Users\Lenovo\Desktop\lj.c(19) : error C2143: syntax error : missing ')' before 'type' C:\Users\Lenovo\Desktop\lj.c(19) : error C2143: syntax error : missing ';' before 'type' C:\Users\Lenovo\Desktop\lj.c(19) : error C2065: 'i' : undeclared identifier C:\Users\Lenovo\Desktop\lj.c(19) : warning C4552: '<' : operator has no effect; expected operator with side-effect C:\Users\Lenovo\Desktop\lj.c(19) : error C2059: syntax error : ')' C:\Users\Lenovo\Desktop\lj.c(19) : error C2143: syntax error : missing ';' before '{' C:\Users\Lenovo\Desktop\lj.c(33) : error C2143: syntax error : missing ';' before 'type' C:\Users\Lenovo\Desktop\lj.c(34) : error C2143: syntax error : missing ';' before 'type' C:\Users\Lenovo\Desktop\lj.c(34) : error C2143: syntax error : missing ';' before 'type' C:\Users\Lenovo\Desktop\lj.c(34) : error C2143: syntax error : missing ')' before 'type' C:\Users\Lenovo\Desktop\lj.c(34) : error C2143: syntax error : missing ';' before 'type' C:\Users\Lenovo\Desktop\lj.c(34) : warning C4552: '<' : operator has no effect; expected operator with side-effect C:\Users\Lenovo\Desktop\lj.c(34) : error C2059: syntax error : ')' C:\Users\Lenovo\Desktop\lj.c(34) : error C2143: syntax error : missing ';' before '{' C:\Users\Lenovo\Desktop\lj.c(35) : error C2065: 'min_index' : undeclared identifier 执行 cl.exe 时出错.
11-19
在VC编程里,error C2143: syntax error : missing ';' before '}' 提示意味着在 '}' 之前缺少分号,而Error executing cl.exe 一般表示编译器(cl.exe)在执行时出错,或许是由于文件路径、权限或者编译器配置方面的问题。以下是一些解决办法: ### 解决 error C2143: syntax error : missing ';' before '}' - **检查代码中的类定义**:在类定义里,成员函数声明或者成员变量定义结束时需要分号。例如: ```cpp class MyClass { public: void myFunction(); // 这里需要分号 }; // 类定义结束处也需要分号 ``` - **检查结构体定义**:结构体定义结束时同样需要分号。例如: ```cpp struct MyStruct { int myVariable; // 成员变量 }; // 结构体定义结束处需要分号 ``` - **检查宏定义**:某些宏定义展开之后可能会造成分号缺失。要确保宏定义正确,并且在使用宏的地方不会产生语法错误。 ### 解决 Error executing cl.exe - **检查文件路径**:保证源文件路径里没有非法字符或者空格。若路径包含空格,需要用引号将路径括起来。 - **检查编译器配置**:确认编译器(cl.exe)的路径配置无误。可以在命令行中输入 `cl.exe` 来测试编译器是否能够正常执行。 - **检查文件权限**:确保源文件和项目文件有足够的读写权限。 - **清理项目并重新编译**:有时候,项目中的临时文件或者缓存文件可能会引发编译错误。可以尝试清理项目,然后重新编译。 ### 示例代码检查 下面是一个可能会引发 error C2143 的示例代码: ```cpp class MyClass { public: void myFunction() { // 函数体 } // 这里缺少分号 } // 错误:缺少分号 int main() { return 0; } ``` 修正后的代码: ```cpp class MyClass { public: void myFunction() { // 函数体 }; // 加上分号 }; // 类定义结束处加上分号 int main() { return 0; } ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值