description | title | ms.date | ms.topic | f1_keywords | helpviewer_keywords | ms.assetid | ||
---|---|---|---|---|---|---|---|---|
Learn more about: C26110 |
C26110 |
10/01/2019 |
reference |
|
|
d82b79ec-6d7f-438b-bd6a-da874a3e08e5 |
warning C26110: Caller failing to hold lock <lock> before calling function <func>.
When a lock is required, make sure to clarify whether the function itself or its caller should acquire the lock. Warning C26110 is issued when there is a violation of the _Requires_lock_held_
annotation, or other lock-related annotations. For more information, see Annotating Locking Behavior
In the following example, warning C26110 is generated because the annotation _Requires_lock_held_
on function LockRequired
states that the caller of LockRequired
must acquire the lock before it calls LockRequired
. Without this annotation, LockRequired
has to acquire the lock before it accesses any shared data protected by the lock.
typedef struct _DATA
{
CRITICAL_SECTION cs;
int d;
} DATA;
_Requires_lock_held_(p->cs)
void LockRequired(DATA* p)
{
p->d = 0;
}
void LockNotHeld(DATA* p)
{
LockRequired(p); // Warning C26110
}