头文件包含顺序问题

错误程序:

#include <xnamath.h>
#include <windows.h>
#include <iostream>
using namespace std;

int main() {
	return 0;
}


该程序在VS2010中编译会产生251个错误。

分析:

xnamath.h头文件中用到了FLOAT数据类型,该类型在windef.h中定义,而windows.h中包含了windef.h,但是包含的顺序导致了xnamath.h中无法识别FLOAT类型,将包含顺序反过来就对了。

#include <windows.h>
#include <xnamath.h>
#include <iostream>
using namespace std;

int main() {
	return 0;
}

 

该错误以前从没遇到过,也花了近一个小时才找到错误。虽然是小BUD但是值得注意。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章