将Visual C ++项目迁移到Visual Studio 2013 - DirectShow基类错误C2169

时间:2016-01-11 11:39:01

标签: c++ visual-studio visual-studio-2013 directshow migrate

我已将Visual C ++项目迁移到Visual Studio 2013.当我尝试构建项目时,编译器返回以下错误:

Error 2 error C2169: '_InterlockedIncrement' : intrinsic function, cannot be defined

错误在combase.h中(来自DirectShow的头文件),代码为:

static inline LONG WINAPI InterlockedIncrement(volatile LONG * plong) { return InterlockedIncrement( const_cast<LONG*>( plong ) ); }

InterlockedIncrement在winnt.h中定义为:

#define InterlockedIncrement _InterlockedIncrement

您是否知道此错误的任何解决方案?

1 个答案:

答案 0 :(得分:1)

您的#define会将所有InterlockedIncrement替换为_InterlockedIncrement,因此static inline LONG WINAPI InterlockedIncrement(volatile LONG * plong)变为static inline LONG WINAPI _InterlockedIncrement(volatile LONG * plong)

这意味着您实际上正在尝试定义_InterlockedIncrement函数,这是禁止的,因为它是内在函数。

我认为你需要删除

#define InterlockedIncrement _InterlockedIncrement

并根据需要使InterlockedIncrement调用_InterlockedIncrement并进行适当的参数转换。