Repository navigation
Expand file tree
/
Copy pathassert_precondition.h
More file actions
55 lines (43 loc) · 1.69 KB
/
Copy pathassert_precondition.h
File metadata and controls
55 lines (43 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* Copyright (c) 2023 Boston Dynamics, Inc. All rights reserved.
*
* Downloading, reproducing, distributing or otherwise using the SDK Software
* is subject to the terms and conditions of the Boston Dynamics Software
* Development Kit License (20191101-BDSDK-SL).
*/
#pragma once
#include <cassert>
#include <exception>
#include <functional>
#include <sstream>
#include <stdexcept>
#include <string>
#ifdef BOSDYN_DISABLE_ASSERTS
// Disables all bosdyn assert checks.
# define BOSDYN_ASSERT_PRECONDITION(cond, ...) ((void)0)
#else
/**
* The SDK uses assertions to check pre-conditions required for specific functions to complete
* successfully.
*
* The BOSDYN_ASSERT_PRECONDITION macro will check a condition, and if it is not met then it will
* report the failure and terminate the program.
*
* If arguments are provided after the condition, then the first argument after condition will be
* used as a printf-style format string, and the following arguments will be used as arguments to
* that format string.
*/
# define BOSDYN_ASSERT_PRECONDITION(cond, ...) \
(!(cond) ? bosdyn::common::panic(__FUNCTION__, __FILE__, __LINE__, #cond, ##__VA_ARGS__) \
: (void)0)
# define BOSDYN_PANIC(...) \
bosdyn::common::panic(__FUNCTION__, __FILE__, __LINE__, "", ##__VA_ARGS__)
#endif
namespace bosdyn {
namespace common {
// Logs a formatted error message with additional debug information, then will terminate the
// program.
[[noreturn]] void panic(char const* function, char const* file, int line, const char* cond,
const char* format, ...);
} // namespace common
} // namespace bosdyn