MS VC++ Intrinsic InterlockedCompareExchange128 関数を使用しようとしています。
hello-world として、16 バイトのアドレスをそれ自体と比較し、それを別のものに置き換えようとしています。これはコンパイルされますが、機能しません。アドレスは新しい値と交換されません。const_cast を使用してコンパイルします (そうしないと、volatile をキャストできないことを叫びます)。
typedef struct t_node
{
volatile __int64 arr[2];
}node;
int main()
{
node *a = new node();
a->arr[0] = 100;
a->arr[1] = 1;
__int64 i = 200;
__int64 j = 500;
char r = _InterlockedCompareExchange128(a->arr, i,j, const_cast<__int64*>(&a->arr[0]));
cout<<endl<<"Interlocked Compare Res: "<<r;
cin.get();
return 0;
}