Assure.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_SRC_BASE_ASSURE_H
10 #define SQUID_SRC_BASE_ASSURE_H
11 
12 #include "base/Here.h"
13 
18 [[ noreturn ]] void ReportAndThrow_(int debugLevel, const char *description, const SourceLocation &);
19 
23 #define Assure_(debugLevel, condition, description, location) \
24  while (!(condition)) \
25  ReportAndThrow_((debugLevel), (description), (location))
26 
27 #if !defined(NDEBUG)
28 
35 #define Assure(condition) \
36  Assure2((condition), #condition)
37 
40 #define Assure2(condition, description) \
41  Assure_(0, (condition), ("assurance failed: " description), Here())
42 
43 #else
44 
45 /* do-nothing implementations for NDEBUG builds */
46 #define Assure(condition) ((void)0)
47 #define Assure2(condition, description) ((void)0)
48 
49 #endif /* NDEBUG */
50 
51 #endif /* SQUID_SRC_BASE_ASSURE_H */
52 
a source code location that is cheap to create, copy, and store
Definition: Here.h:29
void ReportAndThrow_(int debugLevel, const char *description, const SourceLocation &)
Definition: Assure.cc:15

 

Introduction

Documentation

Support

Miscellaneous