summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authormike <mike@FreeBSD.org>2001-10-27 20:11:10 +0000
committermike <mike@FreeBSD.org>2001-10-27 20:11:10 +0000
commit186071821a5c388da21ab0a53f41dfb0eea24cf7 (patch)
treefa20a2f93c4614ce7747af799dd77a495d6132b3 /lib/libc
parentb37309f7648547e5c69ae317a1d73d8b631bd55f (diff)
downloadFreeBSD-src-186071821a5c388da21ab0a53f41dfb0eea24cf7.zip
FreeBSD-src-186071821a5c388da21ab0a53f41dfb0eea24cf7.tar.gz
Only provide function information in compile environments that support
the C99 variable __func__ and never for C++. Provide a more meaningful example in the assert(3) manual. Reviewed by: asmodai, bde
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/assert.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/libc/gen/assert.c b/lib/libc/gen/assert.c
index 9f265b7..7cd4d0c 100644
--- a/lib/libc/gen/assert.c
+++ b/lib/libc/gen/assert.c
@@ -45,14 +45,19 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
void
-__assert(function, file, line, failedexpr)
- const char *function, *file;
+__assert(func, file, line, failedexpr)
+ const char *func, *file;
int line;
const char *failedexpr;
{
- (void)fprintf(stderr,
- "assertion (%s) failed: function %s(), file %s:%d\n",
- failedexpr, function, file, line);
+ if (func == NULL)
+ (void)fprintf(stderr,
+ "assertion (%s) failed: file %s:%d\n", failedexpr,
+ file, line);
+ else
+ (void)fprintf(stderr,
+ "assertion (%s) failed: function %s(), file %s:%d\n",
+ failedexpr, func, file, line);
abort();
/* NOTREACHED */
}
OpenPOWER on IntegriCloud