source: src/libcfa/assert.c @ ccd8bc3

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since ccd8bc3 was 57f408e, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

added a terminating newline to asserts

  • Property mode set to 100644
File size: 1.4 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// assert.c --
8//
9// Author           : Thierry Delisle
10// Created On       : Mon Nov 28 12:27:26 2016
11// Last Modified By : Thierry Delisle
12// Last Modified On : Mon Nov 28 12:27:26 2016
13// Update Count     : 0
14//
15
16#include "assert"
17#include "stdlib"                                                                               // abort
18
19extern "C" {
20        #include <stdarg.h>                                                             // varargs
21        #include <stdio.h>                                                              // fprintf
22
23        extern const char * __progname;                                         // global name of running executable (argv[0])
24
25        #define CFA_ASSERT_FMT "*CFA assertion error* from program \"%s\" in \"%s\" at line %d in file \"%s\""
26
27        // called by macro assert in assert.h
28        void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
29                fprintf( stderr, CFA_ASSERT_FMT ".\n", __progname, function, line, file );
30                abort();
31        }
32
33        // called by macro assertf
34        void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
35                fprintf( stderr, CFA_ASSERT_FMT ": ", __progname, function, line, file );
36                va_list args;
37                va_start( args, fmt );
38                vfprintf( stderr, fmt, args );
39                va_end( args );
40                fprintf( stderr, "\n" );
41                abort();
42        }
43
44}
45
46// Local Variables: //
47// mode: c //
48// tab-width: 4 //
49// End: //
Note: See TracBrowser for help on using the repository browser.