Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
2417 Discussions

error C2733: second C linkage of overloaded function '_InterlockedCompareExchange_np' not allowed

Stewart_Hore1
Beginner
595 Views
Hi All,
I am seeing the above error in our builds since introducing TBB. I managed to determine two sources but it comes back occasionally and is very hard to track down the culprit. Does anyone else get this? Actual error:
C:/devtools/vs9/VC/INCLUDE\\memory(996) : error C2733: second C linkage of overloaded function '_InterlockedCompareExchange_np' not allowed
[exec] C:/devtools/vs9/VC/INCLUDE\\memory(995) : see declaration of '_InterlockedCompareExchange_np'
C:/devtools/vs9/VC/INCLUDE\\memory(996) : error C2733: second C linkage of overloaded function '_InterlockedCompareExchange_np' not allowed [exec] C:/devtools/vs9/VC/INCLUDE\\memory(995) : see declaration of '_InterlockedCompareExchange_np'
But we see it in "winnt.h" as well with several InterlockedXXXX. Thankfully on Mac, Linux and SOLARIS we don't have windows issues. I am assuming this is primarily with tbb/atomic so to reduce the errors problems I am not using atomics or including atomic.h in headers.
1) This happened early on with BOOST. We didn't have BOOST_USE_WINDOWS_H defined as we have some old Inerviews code which is based on MFC (no we don't have time at the moment to upgrade all our old apps). BOOST then went to define some of the _InterlockedXXXX methods itself which broke TBB when the include order was after boost. Turning this on helped, we then just had to be careful with the header ordering for our MFC apps and BOOST. This was easier than TBB as it involved one header in fewer places.
(MFC is pure pain so we have to order headers carefully later in our build with TBB and MFC)
Does anyone have any ideas on a good fix for this? Does anyone know of other third-party libs, not just BOOST where this occurs with TBB? I have searched high and low and only found references to BOOST under WinCE, nothing for TBB.
It may just be our build system but it hasn't failed us in the past (we work very hard to keep it clean and polished).
Any help appreciated, thanks all!
0 Kudos
1 Solution
jimdempseyatthecove
Black Belt
595 Views

long _InterlockedCompareExchange_np (long *, long, long);

Is an intrinsic function. However, your code (someone's code) may be declaring this as not intrinsic.

In the problem file, try including "intrin.h"

Jim Dempsey

View solution in original post

2 Replies
jimdempseyatthecove
Black Belt
596 Views

long _InterlockedCompareExchange_np (long *, long, long);

Is an intrinsic function. However, your code (someone's code) may be declaring this as not intrinsic.

In the problem file, try including "intrin.h"

Jim Dempsey

Stewart_Hore1
Beginner
595 Views
Cheers that worked!
Seems our windows build could do with some more robustness
Reply