Crypto++ 8.9 Free C++ class library of cryptographic schemes

Classes | Macros
trap.h File Reference

Debugging and diagnostic assertions. More...

Go to the source code of this file.

## Classes
class | DebugTrapHandler
| Default SIGTRAP handler. More...

## Macros
#define | CRYPTOPP_ASSERT(exp) { ... }
| Debugging and diagnostic assertion. More...

## Detailed Description

Debugging and diagnostic assertions.

`CRYPTOPP_ASSERT` is the library's debugging and diagnostic assertion. `CRYPTOPP_ASSERT` is enabled by `CRYPTOPP_DEBUG`, `DEBUG` or `_DEBUG`.

`CRYPTOPP_ASSERT` raises a `SIGTRAP` (Unix) or calls `DebugBreak()` (Windows).

`CRYPTOPP_ASSERT` is only in effect when the user requests a debug configuration. `NDEBUG` (or failure to define it) does not affect `CRYPTOPP_ASSERT`.

Since
  Crypto++ 5.6.5

See also
  DebugTrapHandler, Issue 277, CVE-2016-7420

Definition in file trap.h.

## Macro Definition Documentation

## ◆ CRYPTOPP_ASSERT

#define CRYPTOPP_ASSERT | ( |  | exp | ) | { ... }

Debugging and diagnostic assertion.

`CRYPTOPP_ASSERT` is the library's debugging and diagnostic assertion. `CRYPTOPP_ASSERT` is enabled by the preprocessor macros `CRYPTOPP_DEBUG`, `DEBUG` or `_DEBUG`.

`CRYPTOPP_ASSERT` raises a `SIGTRAP` (Unix) or calls `DebugBreak()` (Windows). `CRYPTOPP_ASSERT` is only in effect when the user explicitly requests a debug configuration.

If you want to ensure `CRYPTOPP_ASSERT` is inert, then do not define `CRYPTOPP_DEBUG`, `DEBUG` or `_DEBUG`. Avoiding the defines means `CRYPTOPP_ASSERT` is preprocessed into an empty string.

The traditional Posix define `NDEBUG` has no effect on `CRYPTOPP_DEBUG`, `CRYPTOPP_ASSERT` or DebugTrapHandler.

An example of using CRYPTOPP_ASSERT and DebugTrapHandler is shown below. The library's test program, `cryptest.exe` (from test.cpp), exercises the structure:

      #if defined(CRYPTOPP_DEBUG) && defined(UNIX_SIGNALS_AVAILABLE)
      static const DebugTrapHandler g_dummyHandler;
      #endif

      int main(int argc, char* argv[])
      {
         CRYPTOPP_ASSERT(argv != nullptr);
         ...
      }

Since
  Crypto++ 5.6.5

See also
  DebugTrapHandler, SignalHandler, Issue 277, CVE-2016-7420

Definition at line 68 of file trap.h.