gpt4 book ai didi

delphi - InterLockedIncrement 不支持第二个参数?

转载 作者:行者123 更新时间:2023-12-03 15:39:10 24 4
gpt4 key购买 nike

我想做

InterLockedIncrement(counter, step)

但是编译器说

参数过多

是否有用于获取第二个参数的 API?

最佳答案

InterlockedIncrement()只有一个参数 - 递增 1 的变量:

function InterlockedIncrement(var Addend: Integer): Integer; stdcall;

Increments (increases by one) the value of the specified 32-bit variable as an atomic operation.

Parameters

Addend [in, out]
A pointer to the variable to be incremented.

对于你所问的问题,有一个InterlockedAdd()函数,但在Delphi中不可用。您可以使用 InterlockedExchangeAdd()函数替代:

function InterlockedExchangeAdd(var Addend: Integer; Value: Integer): Integer stdcall;

Performs an atomic addition of two 32-bit values.

Parameters

Addend [in, out]
A pointer to a variable. The value of this variable will be replaced with the result of the operation.

Value [in]
The value to be added to the variable pointed to by the Addend parameter.

关于delphi - InterLockedIncrement 不支持第二个参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33351527/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com