使用 32 位和 64 位架构通用的 C++ InterlockedIncrement 功能的最佳方式是什么?(有分离的功能)
有没有比使用#if _W64
预处理器命令更好的方法?
使用 32 位和 64 位架构通用的 C++ InterlockedIncrement 功能的最佳方式是什么?(有分离的功能)
有没有比使用#if _W64
预处理器命令更好的方法?
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.