首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

vs2010中winnt.h的异常,该如何样解决

2013-07-04 
vs2010中winnt.h的错误,该怎么样解决?我使用opencv2.3.1和vs2010编写的一个工程项目,出现的问题是如下,请

vs2010中winnt.h的错误,该怎么样解决?
我使用opencv2.3.1和vs2010编写的一个工程项目,出现的问题是如下,请各位高手帮忙?
1>c:\program files\microsoft sdks\windows\v7.0a\include\winnt.h(290): error C2146: 语法错误: 缺少“;”(在标识符“PVOID64”的前面)
1>c:\program files\microsoft sdks\windows\v7.0a\include\winnt.h(290): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files\microsoft sdks\windows\v7.0a\include\winnt.h(8992): error C2146: 语法错误: 缺少“;”(在标识符“Buffer”的前面)
1>c:\program files\microsoft sdks\windows\v7.0a\include\winnt.h(8992): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>c:\program files\microsoft sdks\windows\v7.0a\include\winnt.h(8992): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int Visual?Studio?2010 winnt.h
[解决办法]
偶遇到类似问题都是用
“每次用/*...*/注释掉不同部分再重新编译,直到定位到具体语法出错的位置。”
的方法解决的。

[解决办法]
检查
#include<winnt.h>
或者
#include<windoiws.h>
前面的代码,主要是 #include “*.h” 中的你自己定义的头文件里,有没有漏写分号;
或者有没有其他编译器,认为需要分号;而没写的地方。
[解决办法]
http://stackoverflow.com/questions/9923628/syntax-error-missing-before-identifier-pvoid64-when-compiling-winnt-h:

You need to include windows.h rather than winnt.h. When you include windows.h it will, in turn, include winnt.h. You need to do it this way for the necessary macros to be in place that are needed to compile winnt.h.

In this case, POINTER_64 is defined in BaseTsd.h like this:

#define POINTER_64 __ptr64But if you include winnt.h before including windows.h then POINTER_64 is not defined.

如果像以下简单例子只有2条include不会出现LZ所遇到的编译错误:

#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;


using namespace cv;
 
int main(int argc, char* argv[])
{
const char* imagename = "lena.jpg";
 
//从文件中读入图像
Mat img = imread(imagename);
 
//如果读入图像失败
if(img.empty())
{
fprintf(stderr, "Can not load image %s\n", imagename);
return -1;
}
 
//显示图像
imshow("image", img);
 
//此函数等待按键,按键盘任意键就返回
waitKey();
 
return 0;
}


[解决办法]
包含库的头文件顺序引起的,有的需要包含在前面,有的需要包含在后面。

热点排行