关于assert.h文件 在线结贴
#ifndef __assert_h
# define __assert_h
#define _ARMABI_NORETURN __declspec(__nothrow) __declspec(__noreturn)
# undef __CLIBNS
# ifdef __cplusplus
namespace std {
# define __CLIBNS ::std::
extern "C" {
# else
# define __CLIBNS
# endif /* __cplusplus */
extern _ARMABI_NORETURN void abort(void);
extern _ARMABI_NORETURN void __aeabi_assert(const char *, const char *, int) __attribute__((__nonnull__(1,2)));
# ifdef __cplusplus
} /* extern "C" */
} /* namespace std */
# endif
#else
# undef assert
# undef __promise
#endif
#ifdef NDEBUG
# define assert(ignore) ((void)0)
# define __promise(e) ((__promise)((e)?1:0))
#else
# if defined __DO_NOT_LINK_PROMISE_WITH_ASSERT
# if defined __OPT_SMALL_ASSERT && !defined __ASSERT_MSG && !defined __STRICT_ANSI__ && !(_AEABI_PORTABILITY_LEVEL != 0 || (!defined _AEABI_PORTABILITY_LEVEL && __DEFAULT_AEABI_PORTABILITY_LEVEL != 0))
# define assert(e) ((e) ? (void)0 : __CLIBNS abort())
# elif defined __STDC__
# define assert(e) ((e) ? (void)0 : __CLIBNS __aeabi_assert(#e, __FILE__, __LINE__))
# else
# define assert(e) ((e) ? (void)0 : __CLIBNS __aeabi_assert("e", __FILE__, __LINE__))
# endif
# define __promise(e) ((__promise)((e)?1:0))
# else
# if defined __OPT_SMALL_ASSERT && !defined __ASSERT_MSG && !defined __STRICT_ANSI__ && !(_AEABI_PORTABILITY_LEVEL != 0 || (!defined _AEABI_PORTABILITY_LEVEL && __DEFAULT_AEABI_PORTABILITY_LEVEL != 0))
# define assert(e) ((e) ? (void)0 : __CLIBNS abort(), (__promise)((e)?1:0))
# else
# define assert(e) ((e) ? (void)0 : __CLIBNS __aeabi_assert(#e, __FILE__, __LINE__), (__promise)((e)?1:0))
# endif
# define __promise(e) assert(e)
# endif
#endif
#if _AEABI_PORTABILITY_LEVEL != 0 && !defined _AEABI_PORTABLE
#define _AEABI_PORTABLE
#endif
===========================================================
在线等。越详细越好。红色部分。
1、define为什么加了3个参数。
2、一个声明中怎么又2个函数?
[解决办法]
extern _ARMABI_NORETURN void __aeabi_assert(const char *, const char *, int) __attribute__((__nonnull__(1,2)))
--- 这个是一个函数啊,楼主怎么说是两个?
[解决办法]
define就是预编译时的字符串替换。还可以跟长长的代码段呢
[解决办法]
__declspec
是C++的键字,它可以用来修饰函数
#define _ARMABI_NORETURN __declspec(__nothrow) __declspec(__noreturn)
定义了一个_ARMABI_NORETURN ,它是函数的修饰其中
nothrow :
格式:return-type __declspec(nothrow) [call-convention] function-name ([argument-list])
可用于函数声明。告诉编译器被声明的函数以及函数内部调用的其它函数都不会抛出异常。
noreturn :
一个函数被__declspec(noreturn)所修饰,那么它的含义是告诉编译器,这个函数不会返回,其结果是让编译器知道被修饰为__declspec(noreturn)的函数之后的代码不可到达。
如果编译器发现一个函数有无返回值的代码分支,编译器将会报C4715警告,或者C2202错误信息。如果这个代码分支是因为函数不会返回从而无法到达的话,可以使用约定__declspec(noreturn)来避免上述警告或者错误。
将一个期望返回的函数约定为__declspec(noreturn)将导致未定义的行为。
extern _ARMABI_NORETURN void __aeabi_assert(const char *, const char *, int) __attribute__((__nonnull__(1,2)));
相当与
extern __declspec(__nothrow) __declspec(__noreturn) void __aeabi_assert(const char *, const char *, int) __attribute__((__nonnull__(1,2)));
这个函数有三个修饰
__declspec(__nothrow)
__declspec(__noreturn)
void
[解决办法]
__aeabi_assert是函数,__attribute__是函数的另一修饰(gcc特有的)
[解决办法]