在Windows XP上使用Visual Studio 2005进行编译。我添加下面的标题我的“stdafx.h中”文件,像这样:添加包含导致编译错误
#include <atlbase.h>
#include <atlcom.h>
#include <atlcore.h>
#include <atlstr.h>
(技术上只有atlbase.h包括出现相同的错误),它产生以下错误:
error C2334: unexpected token(s) preceding '{'; skipping apparent function body
error C2062: type 'double' unexpected
在以下代码:
struct CheckValue : public unary_function<pair<MetID,double>,void>{
CheckValue(double _expected) : m_Expected(_expected){}
inline void operator()(const pair<MetID,double> &_val){
m_CheckList.push_back(near(_val.second) ? 0 : 1);
}
inline bool near(double _val){ //here is location of both errors
return (m_Expected - m_Epsilon < _val) || (_val < m_Expected + m_Epsilon);
}
const static double m_Epsilon;
const double m_Expected;
list<int> m_CheckList;
};
const double CheckValue::m_Epsilon = 0.00001;
没有添加这些行,没有问题。任何人都想冒险猜测为什么?我在这里摸不着头脑,无法继续编写没有包含文件的单元测试。
好点,让我编辑,让你可以知道错误发生的地方 – wheaties 2010-10-06 20:26:17
+1这比我的答案更可能。 :) – casablanca 2010-10-06 20:28:35
这是它,谢谢。我讨厌他们的@#$#$%宏,它们会覆盖标准库的limits :: max()或limits :: min()。 – wheaties 2010-10-06 20:29:01