2

我使用的是 OpenCV,并且在安装 Microsoft Platform SDK 以使用 OpenGL 之后,在尝试编译我的 opencv 项目时会出现这些错误。

1>d:\program files\microsoft platform sdk for windows server 2003 r2\include\winnt.h(2645) : error C2733: second C linkage of overloaded function '_interlockedbittestandset' not allowed
1>        d:\program files\microsoft platform sdk for windows server 2003 r2\include\winnt.h(2642) : see declaration of '_interlockedbittestandset'
1>d:\program files\microsoft platform sdk for windows server 2003 r2\include\winnt.h(2651) : error C2733: second C linkage of overloaded function '_interlockedbittestandreset' not allowed
1>        d:\program files\microsoft platform sdk for windows server 2003 r2\include\winnt.h(2648) : see declaration of '_interlockedbittestandreset'
4

2 回答 2

1

这个解决方案解决了我的问题。

请注意,在下面的此修复之前,您必须确保intrin.h不会意外包含(例如,您使用的某些其他头文件) 。

#if _MSC_VER >= 1400
//  Following 8 lines: workaround for a bug in some older SDKs
#   pragma push_macro("_interlockedbittestandset")
#   pragma push_macro("_interlockedbittestandreset")
#   pragma push_macro("_interlockedbittestandset64")
#   pragma push_macro("_interlockedbittestandreset64")
#   define _interlockedbittestandset _local_interlockedbittestandset
#   define _interlockedbittestandreset _local_interlockedbittestandreset
#   define _interlockedbittestandset64 _local_interlockedbittestandset64
#   define _interlockedbittestandreset64 _local_interlockedbittestandreset64
#   include <intrin.h> // to force the header not to be included elsewhere
#   pragma pop_macro("_interlockedbittestandreset64")
#   pragma pop_macro("_interlockedbittestandset64")
#   pragma pop_macro("_interlockedbittestandreset")
#   pragma pop_macro("_interlockedbittestandset")
#endif
于 2013-08-29T08:07:05.350 回答
0

分辨率:http ://stefanobolli.blogspot.com/2010/10/compiler-error-c2733-second-c-linkage.html

于 2011-10-15T01:56:45.197 回答