体系结构 - 通用InterlockedIncrement for 32/64-bit

时间:2013-11-28 11:40:50

标签: c++ 64-bit 32bit-64bit interlocked interlocked-increment

对32位和64位架构使用C ++ InterlockedIncrement功能的最佳方法是什么? (有分开的功能)

有没有比使用#if _W64预处理器命令更好的方法?

1 个答案:

答案 0 :(得分:0)

最简单的解决方案,因为您正在使用C ++:

inline LONGLONG __cdecl InterlockedIncrement(LONGLONG volatile *Addend)
{
  return InterlockedIncrement64(Addend);
);

现在,您可以在32位和64位构建中无条件地对32位或64位变量调用InterlockedIncrement