assert.h (2179B)
1/** 2 * WinPR: Windows Portable Runtime 3 * Runtime ASSERT macros 4 * 5 * Copyright 2021 Armin Novak <armin.novak@thincast.com> 6 * Copyright 2021 Thincast Technologies GmbH 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21#ifndef WINPR_ASSERT_H 22#define WINPR_ASSERT_H 23 24#include <stdlib.h> 25#include <winpr/winpr.h> 26#include <winpr/wtypes.h> 27#include <winpr/wlog.h> 28#include <winpr/debug.h> 29 30#if defined(WITH_VERBOSE_WINPR_ASSERT) && (WITH_VERBOSE_WINPR_ASSERT != 0) 31#define WINPR_ASSERT(cond) \ 32 do \ 33 { \ 34 if (!(cond)) \ 35 { \ 36 wLog* _log_cached_ptr = WLog_Get("com.freerdp.winpr.assert"); \ 37 WLog_Print(_log_cached_ptr, WLOG_FATAL, "%s [%s:%s:%" PRIuz "]", #cond, __FILE__, \ 38 __FUNCTION__, __LINE__); \ 39 winpr_log_backtrace_ex(_log_cached_ptr, WLOG_FATAL, 20); \ 40 abort(); \ 41 } \ 42 } while (0) 43#else 44#define WINPR_ASSERT(cond) \ 45 do \ 46 { \ 47 } while (0) 48#endif 49 50#ifdef __cplusplus 51extern "C" 52{ 53#endif 54 55#ifdef __cplusplus 56} 57#endif 58 59#endif /* WINPR_ERROR_H */