error C2144: 语法错误:“int”的前面应有“;”
来源:互联网 发布:golang mgo 编辑:程序博客网 时间:2024/05/18 07:59
error C2144: 语法错误:“int”的前面应有“;”
C++- error C2144 syntax error : ‘int’ should be preceded by ‘;’
注:我使用VS2010时,遇到的问题。
解决办法
在某个.h文件里你自定义的某个类最后的“;”,你一定使用的是中文输入法下的“;”,将它换为英文输入法,输入”;“。问题解决。
注意:
中文输入法下的“;”和英文输入法下的“;”实在是太像了。
实例
错误程序
main.cpp
#include <iostream>#include "helloworld.h"int main(void){ HelloWorld hello; hello.say(); while(1){} return 0;}
helloworld.h
#ifndef __HELLOWORLD_H_#define __HELLOWORLD_H_class HelloWorld{public: HelloWorld(){} void say(){ std::cout << "Hello World!" << std::endl; }};#endif
编译失败:
1> main.cpp : error C2144: 语法错误:“int”的前面应有“;”1>1>生成失败。
修改后正确的程序
修改helloworld.h
#ifndef __HELLOWORLD_H_#define __HELLOWORLD_H_class HelloWorld{public: HelloWorld(){} void say(){ std::cout << "Hello World!" << std::endl; }};#endif
编译成功:
1>生成成功。
注意:
另一种解决办法,(但是我不推荐使用):在main.cpp的main()函数返回变量
int
前面加上一个“;
”。也可以解决问题。
#include <iostream>#include "helloworld.h" ;int main(void){ HelloWorld hello; hello.say(); while(1){} return 0;}
参考网站:
1. http://stackoverflow.com/questions/11808432/c-error-c2144-syntax-error-int-should-be-preceded-by
0 0
- error C2144: 语法错误:“int”的前面应有“;”
- error C2144: 语法错误:“__w64 unsigned int”的前面应有“;
- error C2144: 语法错误 : “void”的前面应有“;”
- Clapack.h small error C2144: 语法错误:“char”的前面应有“;”
- error C2144: 语法错误 : “void”的前面应有“;” error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int;
- error C2143: 语法错误 : 缺少“)”(在“&”的前面)
- error C2143: 语法错误 : 缺少“;”(在“{”的前面)
- error C2143: 语法错误 : 缺少“;”(在“*”的前面)
- error C2143: 语法错误 : 缺少“;”(在“{”的前面)
- error C2143: 语法错误 : 缺少";"(在"*"的前面)
- error C2143 语法错误 缺少“;”(在“”的前面)
- error C2143: 语法错误 : 缺少“;”(在“*”的前面)
- C++错误:“__w64 unsigned int”的前面应有“;”
- C++错误:“__w64 unsigned int”的前面应有“;“
- 关于奇怪的错误error C2144: syntax error : '__w64 unsigned int' should be preceded by ';'
- error C2146: 语法错误: 缺少“;”(在标识符“WINAPI”的前面) 及 “error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int” 解决方案
- error C2146: 语法错误: 缺少“;”(在标识符“m_tTimer”的前面) error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C2144: syntax error: 'int' should be preceded by ';'
- C语言中getchar()和putchar()的实现细节
- nginx图片服务器nginx.conf配置
- ps -ef命令详解
- Hibernate基本概念
- Exynos4412裸机开发 —— RTC 实时时钟单元
- error C2144: 语法错误:“int”的前面应有“;”
- SpringMVC与Struts2的对比
- HttpURLConnection
- Android计算进程数及剩余内存
- PHP单个图片上传
- android 同心圆水波纹的实现
- 【CSS】CSS简介
- Exynos4412裸机开发——中断处理
- android 网络通信之HttpURLConnection与HttpClient