Keir Mierle | 3cee879 | 2020-01-22 17:08:13 -0800 | [diff] [blame] | 1 | .. _chapter-pw-assert: |
| 2 | |
| 3 | .. default-domain:: cpp |
| 4 | |
| 5 | .. highlight:: cpp |
| 6 | |
| 7 | --------- |
| 8 | pw_assert |
| 9 | --------- |
| 10 | Pigweed's assert module provides facilities for applications to check |
| 11 | preconditions. The module is split into two components: |
| 12 | |
| 13 | 1. The facade (this module) which is only a macro interface layer |
| 14 | 2. The backend, provided elsewhere, that implements the low level checks |
| 15 | |
| 16 | Basic usage example |
| 17 | ------------------- |
| 18 | |
| 19 | .. code-block:: cpp |
| 20 | |
| 21 | #include "pw_assert/assert.h" |
| 22 | |
| 23 | int main() { |
| 24 | bool sensor_running = StartSensor(&msg); |
| 25 | PW_CHECK(sensor_running, "Sensor failed to start; code: %s", msg); |
| 26 | } |
| 27 | |