📄 hal_assert.h
字号:
/**************************************************************************************************
Filename:
Revised: $Date: 2007-01-29 10:43:59 -0800 (Mon, 29 Jan 2007) $
Revision: $Revision: 13400 $
Description:
Describe the purpose and contents of the file.
Copyright (c) 2006 by Texas Instruments, Inc.
All Rights Reserved. Permission to use, reproduce, copy, prepare
derivative works, modify, distribute, perform, display or sell this
software and/or its documentation for any purpose is prohibited
without the express written consent of Texas Instruments, Inc.
**************************************************************************************************/
#ifndef HAL_ASSERT_H
#define HAL_ASSERT_H
/* ------------------------------------------------------------------------------------------------
* Macros
* ------------------------------------------------------------------------------------------------
*/
/*
* HAL_ASSERT( expression ) - The given expression must evaluate as "true" or else the assert
* handler is called. From here, the call stack feature of the debugger can pinpoint where
* the problem occurred.
*
* HAL_ASSERT_FORCED( ) - If asserts are in use, immediately calls the assert handler.
*
* HAL_ASSERT_STATEMENT( statement ) - Inserts the given C statement but only when asserts
* are in use. This macros allows debug code that is not part of an expression.
*
* HAL_ASSERT_DECLARATION( declaration ) - Inserts the given C declaration but only when asserts
* are in use. This macros allows debug code that is not part of an expression.
*
* Asserts can be disabled for optimum performance and minimum code size (ideal for
* finalized, debugged production code). To disable, define the preprocessor
* symbol HALNODEBUG at the project level.
*/
#ifdef HALNODEBUG
#define HAL_ASSERT(expr)
#define HAL_ASSERT_FORCED()
#define HAL_ASSERT_STATEMENT(statement)
#define HAL_ASSERT_DECLARATION(declaration)
#else
#define HAL_ASSERT(expr) st( if (!( expr )) halAssertHandler(); )
#define HAL_ASSERT_FORCED() halAssertHandler()
#define HAL_ASSERT_STATEMENT(statement) st( statement )
#define HAL_ASSERT_DECLARATION(declaration) declaration
#endif
/*
* This macro compares the size of the first parameter to the integer value
* of the second parameter. If they do not match, a compile time error for
* negative array size occurs (even gnu chokes on negative array size).
*
* This compare is done by creating a typedef for an array. No variables are
* created and no memory is consumed with this check. The created type is
* used for checking only and is not for use by any other code. The value
* of 10 in this macro is arbitrary, it just needs to be a value larger
* than one to result in a positive number for the array size.
*/
#define HAL_ASSERT_SIZE(x,y) typedef char x ## _assert_size_t[-1+10*(sizeof(x) == (y))]
/* ------------------------------------------------------------------------------------------------
* Prototypes
* ------------------------------------------------------------------------------------------------
*/
void halAssertHandler(void);
/**************************************************************************************************
*/
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -