Changeset 1cb2282 for src/main.cc


Ignore:
Timestamp:
Aug 18, 2016, 4:59:11 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
99cad3aa
Parents:
3b8e52c
Message:

add new assert macro for printing message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    r3b8e52c r1cb2282  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 17 22:13:38 2016
    13 // Update Count     : 341
     12// Last Modified On : Thu Aug 18 16:33:49 2016
     13// Update Count     : 347
    1414//
    1515
     
    7070static void dump( std::list< Declaration * > & translationUnit, std::ostream & out = std::cout );
    7171
    72 //************************************************
    73 
    74 #define __STRINGIFY__(str) #str
    75 #define __VSTRINGIFY__(str) __STRINGIFY__(str)
    76 #define assertf(expr, fmt, ...) ((expr) ? static_cast<void>(0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ ))
    77 #define CFA_ASSERT_FMT "*CFA assertion error* from program \"%s\" in \"%s\" at line %d in file \"%s\": "
    78 
    79 extern const char * __progname;                                                 // global name of running executable (argv[0])
    80 // called by macro assert in assert.h
    81 void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
    82         fprintf( stderr, CFA_ASSERT_FMT, __progname, function, line, file );
    83         exit( EXIT_FAILURE );
    84 }
    85 
    86 #include <cstdarg>
    87 // called by macro assertf
    88 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
    89         fprintf( stderr, CFA_ASSERT_FMT, __progname, function, line, file );
    90         va_list args;
    91         va_start( args, fmt );
    92         vfprintf( stderr, fmt, args );
    93         exit( EXIT_FAILURE );
    94 }
    95 
    96 //************************************************
    97 
    9872int main( int argc, char * argv[] ) {
    9973        FILE * input;                                                                           // use FILE rather than istream because yyin is FILE
     
    408382} // dump
    409383
    410 
    411 
    412384// Local Variables: //
    413385// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.