llvm-mos-sdk
assert.h
Go to the documentation of this file.
1 // Copyright 2022 LLVM-MOS Project
2 // Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
3 // See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
4 // information.
5 
6 // Originally from the Public Domain C library (PDCLib).
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #include <__internal.h>
13 
14 #ifndef _ASSERT_H
15 #define _ASSERT_H
16 void __assert(const char *file, const char *line, const char *function,
17  const char *expr);
18 #endif
19 
20 /* If NDEBUG is set, assert() is a null operation. */
21 #undef assert
22 
23 #ifdef NDEBUG
24 #define assert(ignore) ((void)0)
25 #else
26 // Breaking this apart by component saves space.
27 #define assert(expression) \
28  ((expression) ? (void)0 \
29  : __assert(__FILE__, _VALUE_TO_STRING(__LINE__), __func__, \
30  #expression))
31 #endif
32 
33 #ifdef __cplusplus
34 }
35 #endif