ATL(atlalloc.h)在编译时会产生错误

时间:2014-02-16 12:20:31

标签: c++ visual-c++ atl

编译我的代码时,编译器会出现一些错误。 错误:

Error   1   error C2039: 'AtlThrowImpl' : is not a member of 'ATL'  e:\program files\microsoft visual studio 9.0\vc\include\atlalloc.h  184
Error   7   error C2039: 'AtlThrowImpl' : is not a member of 'ATL'  e:\program files\microsoft visual studio 9.0\vc\include\atlalloc.h  184
Error   11  error C2039: 'AtlThrowImpl' : is not a member of 'ATL'  e:\program files\microsoft visual studio 9.0\vc\include\atlalloc.h  184
Error   16  error C2039: 'AtlThrowImpl' : is not a member of 'ATL'  e:\program files\microsoft visual studio 9.0\vc\include\atlalloc.h  184
Error   22  error C2039: 'AtlThrowImpl' : is not a member of 'ATL'  e:\program files\microsoft visual studio 9.0\vc\include\atlalloc.h  184

这是标题的代码部分:

    template <typename T>
inline T AtlThrow(T tLeft, T    tRight)
{
    T tResult;
    HRESULT hr=AtlAdd(&tResult, tLeft, tRight);
    if(FAILED(hr))
    {
        AtlThrow(hr);
    }
    return tResult;
}

我的问题:如何从标题中修复此错误?我是否需要安装一些关于ATL的sdk或其他东西?

1 个答案:

答案 0 :(得分:2)

您的代码中有一些内容从编译器输入中排除AtlThrowImpl

  • 你以某种方式排除<atlexcept.h>
  • 或者,您已定义_ATL_NO_EXCEPTIONS
  • 或者,您已定义_ATL_CUSTOM_THROW
  • 或者,您已__ATLEXCEPT_H__定义了其他内容,然后加入<atlexcept.h>

AtlThrowImpl位于atlexcept.h中,在您面前有完整的项目,您可以检查确切的冲突并排除它。