0

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

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

4

1 回答 1

0

The easiest solution, since you're using C++:

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

Now you can unconditionally call InterlockedIncrement on either 32 bits or 64 bits variables, in both 32 and 64 bits builds.

于 2013-11-28T17:09:49.923 回答