C2143: 在某类型前缺分号--VC里面的各种问题,应该首先查阅msdn
来源:互联网 发布:淘宝分享有礼效果怎样 编辑:程序博客网 时间:2024/06/08 00:07
今天将P_Demo.cpp=>P_Demo.c。
里面某函数体定义如下:
就报如下错误
p_demo.c(68) : error C2275: 'TSint32' : illegal use of this type as an expression
让我去../NY_ipp.h(60) : see declaration of 'TSint32'
p_demo.c(68) : error C2146: syntax error : missing ';' before identifier 'nImageWidth'
p_demo.c(68) : error C2065: 'nImageWidth' : undeclared identifier
而NY_ipp.h中定义TSint32如下:
typedef signed int TSint32;
这显然是没有任何问题的。去查错误类型C2275,找不到任何信息。
以为是程序识别不了我定义的TSint32。没办法,只好将TSint32替换成signed int
结果它仍然报错
p_demo.c(68) : error C2143: syntax error : missing ';' before 'type'
再去msdn中去查该错误,这下就有戏了。MSDN解释如下:
PRB: Executable Code Between Declarations Causes C2143 or C2144
ID: Q58559
SYMPTOMS
In Microsoft C, compiler errors C2143 and C2144 are defined as follows:
C2143: syntax error : missing 'token1' before 'token2'
C2144: syntax error : missing 'token' before type 'type'
CAUSE
You may receive this error message if your program places executable code before a data declaration, an acceptable practice in Kernighan-and-Ritchie C. This practice has been outlawed in later versions of the ANSI drafts.
This error message will normally occur if a required closing curly brace (}), right parenthesis [)], or semicolon (;) is missing. 声明语句放在执行语句后面了,虽然K&R C允许,但是ANSI C不允许!
RESOLUTION
Placing all data declarations before all executable code corrects the programming error.
void main( )
{
int i;
printf( "Hello world!/n" );
{
int j;
}
}
NOTE: In the C++ language, it is legal to declare data within a block of executable code.
注意:C++中允许在执行语句模块(即一对大括号)中声明数据;
MORE INFORMATION
The following code demonstrates this error message:
Sample Code
Compiling this code with a version of Microsoft C prior to C/C++ 7.0 will return the
following error message:
C2144: syntax error : missing ';' before type 'int'
C/C++ version 7.0 and Visual C/C++ issue the following error:
C2143: syntax error : missing ';' before 'type'
- C2143: 在某类型前缺分号--VC里面的各种问题,应该首先查阅msdn
- 软件测试前应该首先考虑的16个问题
- error C2143:语法错误 : 缺少“;”(在“类型”的前面)的解决方案
- error C2143: 语法错误 : 缺少“;”(在“类型”的前面)
- VS2008:error C2143: 语法错误 : 缺少“;”(在“类型”的前面)
- error C2143: 语法错误 : 缺少“;”(在“类型”的前面)
- VS2012 error C2143: 语法错误 : 缺少“;”(在“类型”的前面)
- error C2143: 语法错误 : 缺少“;”(在“类型”的前面)
- error C2143: 语法错误 : 缺少“;”(在“类型”的前面)
- error C2143:语法错误:缺少";"(在“类型”的前面)
- 【C】error C2143: 语法错误 : 缺少“;”(在“类型”的前面)
- error C2143: 语法错误 : 缺少“;”(在“类型”的前面)
- VC各种类型的
- 在各种字符串类型之间进行转换(MSDN)
- 在VC中使用资源文件应该注意的问题
- typedef 在类里面定义一个类型时的问题。
- CSS里面逗号和分号的区别
- reactJS的return里面不要有分号
- N的阶乘,别人写的……保存起来自己以后看
- 在一个MFC的对话框应用程序中,实现程序开始时就隐藏对话框界面方法(收集)
- Linux下minicom的配置和使用方法
- 树状结构
- shell中的正则表达式、sed、awk
- C2143: 在某类型前缺分号--VC里面的各种问题,应该首先查阅msdn
- javascript继承
- vivi的配置与编译
- php的exec()函数执行外部Linux脚本问题
- (2010)最新Dev-C++与Allegor平台的搭建方法
- jQuery入门指南教程
- VS2008与VC6.0的变化
- 年度最受关注十大Visual Studio插件
- Granule:Oracle内存机制