Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Latest commit

 

History

History
37 lines (30 loc) · 960 Bytes

c26101.md

File metadata and controls

37 lines (30 loc) · 960 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Warning C26101
Warning C26101
11/04/2016
C26101
C26101
86046553-09ec-40ce-82b3-fd641928f0b0

Warning C26101

Failing to use interlocked operation properly for variable 'var'.

Windows APIs offer various interlocked operations. Annotation _Interlocked_ specifies that a variable should only be accessed through an interlocked operation. Warning C26101 is issued when a variable access isn't consistent with the _Interlocked_ annotation.

Example

The following example generates warning C26101 because there's a violation of the _Interlocked_ contract.

CRITICAL_SECTION cs;
typedef struct _DATA
{
    _Interlocked_ LONG data;
} DATA;

void Safe(DATA* p)
{
    InterlockedIncrement(&p->data); // OK
}

void Unsafe(DATA* p)
{
    p->data += 1; // Warning C26101
    EnterCriticalSection(&cs);
    LeaveCriticalSection(&cs);
}