C28112
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
warning C28112: A variable which is accessed via an Interlocked function must always be accessed via an Interlocked function
See line number: It is not always safe to access a variable which is accessed via the Interlocked* family of functions in any other way.
A variable that is accessed by using the Interlocked executive support routines, such as InterlockedCompareExchangeAcquire, is later accessed by using a different method.Although certain ordinary assignments, accesses, and comparisons to variables that are used by the Interlocked* routines can be safely accessed by using a different method, the risk is great enough to justify examining each instance.
Example
The following code example generates this warning:
inter_var --;
...
InterlockedIncrement(&inter_var);
The following code example avoids this warning:
InterlockedDecrement(&inter_var);
...
InterlockedIncrement(&inter_var);