source: src/Common/Assert.cc @ 1cb2282

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 1cb2282 was 1cb2282, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

add new assert macro for printing message

  • Property mode set to 100644
File size: 1.3 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.cc --
8//
9// Author           : Peter A. Buhr
10// Created On       : Thu Aug 18 13:26:59 2016
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Aug 18 16:32:47 2016
13// Update Count     : 7
14//
15
16
17#include <assert.h>
18#include <cstdarg>
19#include <cstdio>
20#include <cstdlib>
21
22extern const char * __progname;                                                 // global name of running executable (argv[0])
23
24#define CFA_ASSERT_FMT "*CFA assertion error* from program \"%s\" in \"%s\" at line %d in file \"%s\""
25
26// called by macro assert in assert.h
27void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
28        fprintf( stderr, CFA_ASSERT_FMT ".\n", __progname, function, line, file );
29        exit( EXIT_FAILURE );
30}
31
32// called by macro assertf
33void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
34        fprintf( stderr, CFA_ASSERT_FMT ": ", __progname, function, line, file );
35        va_list args;
36        va_start( args, fmt );
37        vfprintf( stderr, fmt, args );
38        exit( EXIT_FAILURE );
39}
40
41// Local Variables: //
42// tab-width: 4 //
43// mode: c++ //
44// compile-command: "make install" //
45// End:  //
46
Note: See TracBrowser for help on using the repository browser.