OpenCV下的’IplImage’ : undeclared identifier错误解决(stdafx.h位置)

这个是错的,原因在于#include “stdafx.h”不能放最后

#include "highgui.h"
#include "cv.h"
#include "stdafx.h"

int main(int argc, char* argv[])
{
  IplImage* pImg;

  return 0;
}


调换位置就可以了.

#include "stdafx.h"
#include "highgui.h"
#include "cv.h"

int main(int argc, char* argv[])
{
  IplImage* pImg;

  return 0;
}

原因是:
一般系统预编译的头文件包含在”stdafx.h” ,所谓头文件预编译,就是把一个工程中使用的一些标准头文件(如Windows.H、Afxwin.H)预先编译,以后该工程编译时,不再编译这部分头文件,仅仅使用预编译的结果。这样可以加快编译速度,节省时间。
编译器通过一个头文件stdafx.h来使用预编译头文件。stdafx.h这个头文件名是可以在project的编译设置里指定的。编译器认为,所有在指令#include “stdafx.h”前的代码都是预编译的,它跳过#include “stdafx. h”指令,使用projectname.pch编译这条指令之后的所有代码。
因此,所有的CPP实现文件第一条语句都是:#include “stdafx.h”。

5 comments

  1. marion 说道:

    加了你的链接。希望交换友情链接

    灿烂小屋
    http://www.icanlan.cn

  2. Quake 说道:

    我会经常来的
    我刚刚开始学C

  3. Denis Portela 说道:

    I just want to mention I’m new to blogging and really liked this web page. Probably I’m want to bookmark your blog post . You certainly come with perfect stories. Cheers for sharing your webpage.

  4. Abby Neugin 说道:

    I have really noticed that credit restoration activity really needs to be conducted with techniques. If not, it’s possible you’ll find yourself endangering your ranking. In order to be successful in fixing your credit history you have to ascertain that from this moment in time you pay all your monthly costs promptly before their booked date. It is really significant because by not accomplishing that area, all other activities that you will decide to use to improve your credit rating will not be useful. Thanks for revealing your suggestions.

发表评论

电子邮件地址不会被公开。