Errors while Compiling in Visual C++ 2008, after installation of MS Platform SDK

為{幸葍}努か 提交于 2019-12-02 04:46:38

问题


I was using OpenCV and after I installed Microsoft Platform SDK to work with OpenGL these errors are showing up when trying to compile my opencv project.

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'

回答1:


This solution solved my issue.

Take note that you must ensure that intrin.h does not get accidentally included (e.g. by some other header file you use) before this fix below.

#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



回答2:


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



来源:https://stackoverflow.com/questions/7775209/errors-while-compiling-in-visual-c-2008-after-installation-of-ms-platform-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!