mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-02-06 04:30:13 +00:00
Include the function name in assertion failure messages.
This is required by C99 and later, enabled by the availability of __func__. This requires an updated assertion-printing function in ORCALib. Unfortunately, GNO has the assertion-printing function in its libc rather than in ORCALib, because it calls the GNO implementation of stdio. Therefore, we continue to use the old form under GNO for now, to maintain compatibility with its existing libc.
This commit is contained in:
parent
aa5b239824
commit
08dbe1eea3
@ -15,15 +15,20 @@
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define assert(expression) (expression) ? ((void) 0) : (__assert(__FILE__, __LINE__, #expression))
|
||||
#ifndef __GNO__
|
||||
#define assert(expression) (expression) ? ((void) 0) : (__assert2(__FILE__, __LINE__, __func__, #expression))
|
||||
#else
|
||||
#define assert(expression) ((void) 0)
|
||||
#define assert(expression) (expression) ? ((void) 0) : (__assert(__FILE__, __LINE__, #expression))
|
||||
#endif
|
||||
#else
|
||||
#define assert(expression) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifndef __assert__
|
||||
#define __assert__
|
||||
|
||||
extern void __assert(char *, int, char *);
|
||||
extern void __assert(const char *, unsigned, const char *);
|
||||
extern void __assert2(const char *, unsigned, const char *, const char *);
|
||||
|
||||
#define static_assert _Static_assert
|
||||
|
||||
|
4
cc.notes
4
cc.notes
@ -244,9 +244,9 @@ p. 343
|
||||
|
||||
The documentation states that assert() uses exit(-1) to exit a program. Actually, it uses abort().
|
||||
|
||||
Beginning with ORCA/C 2.1, assert() prints a string that includes the assertion itself, not just the line number and file name. The assertion has the form
|
||||
Beginning with ORCA/C 2.1, assert() prints a string that includes the assertion itself, not just the line number and file name. Beginning with ORCA/C 2.2.0 B5, it also includes the name of the enclosing function. The assertion has the form
|
||||
|
||||
Assertion failed: file :hd:foo.cc, line 47; assertion: bar==1
|
||||
Assertion failed: file :hd:foo.cc, line 47, function fn; assertion: bar==1
|
||||
|
||||
The documentation states assert() writes to stdout. Beginning with ORCA/C 2.1, it writes to stderr.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user