Changeset bc428ca in git


Ignore:
Timestamp:
Mar 26, 1997, 5:20:48 PM (27 years ago)
Author:
Jens Schmidt <schmidt@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b52fc4b2495505785981d640dcf7eb3e456778ef')
Children:
c78b18b1fa50e52018c1f01004e35a9cda192bd7
Parents:
e6969ddbbf9ecd2b6c17103eaf463d35c0386d36
Message:
NDEBUG renamed to NOASSERT
ASSERT1 added
DEBUGOUTPUT-functionality moved to debug.h
WARN- and PVIRT-functionality added


git-svn-id: file:///usr/local/Singular/svn/trunk@79 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/assert.h

    re6969d rbc428ca  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: assert.h,v 1.1 1996-12-05 18:19:31 schmidt Exp $ */
     2/* $Id: assert.h,v 1.2 1997-03-26 16:20:48 schmidt Exp $ */
    33
    44/*
    55$Log: not supported by cvs2svn $
     6Revision 1.1  1996/12/05 18:19:31  schmidt
     7``Unconditional'' check-in.
     8Now it is my turn to develop factory.
     9
    610Revision 1.0  1996/05/17 10:59:37  stobbe
    711Initial revision
     
    913*/
    1014
     15/* This is for backward compatibility only */
     16#if defined (NDEBUG) && ! defined (NOASSERT)
     17#define NOASSERT
     18#endif
     19
    1120/* It should be possible to include this file multiple times for different */
    12 /* settings of NDEBUG */
     21/* settings of NOASSERT */
    1322
     23#undef __ASSERT
     24#undef __ASSERT1
     25#undef STICKYASSERT
    1426#undef ASSERT
    15 #undef __ASSERT
    16 #undef STICKYASSERT
    17 #undef DEBOUT
    18 #undef DEBOUTLN
     27#undef ASSERT1
     28
     29#undef __WARN
     30#undef STICKYWARN
     31#undef WARN
     32
     33#undef PVIRT_VOID
     34#undef PVIRT_INTCF
     35#undef PVIRT_BOOL
     36#undef PVIRT_INT
     37#undef PVIRT_CHARCC
    1938
    2039#include <stdio.h>
    2140#include <stdlib.h>
    2241
    23 #ifdef NDEBUG
    24 #define ASSERT(ignore1,ignore2)((void)0)
    25 #else
    26 #define ASSERT(expression,message) \
    27 ((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__)))
    28 #endif
    29 
    30 #define STICKYASSERT(expression,message) \
     42#define __ASSERT(expression, message, file, line) \
     43(fprintf( stderr, "error: " message "\n%s:%u: failed assertion `%s'\n", \
     44 file, line, expression ), abort(), 0 )
     45#define __ASSERT1(expression, message, parameter1, file, line)  \
     46(fprintf( stderr, "error: " message "\n%s:%u: failed assertion `%s'\n", \
     47 parameter1, file, line, expression ), abort(), 0 )
     48#define STICKYASSERT(expression, message) \
    3149((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__)))
    3250
    33 #define __ASSERT(expression, message, file, line)  \
    34 (fprintf( stderr, "error: %s\n%s:%u: failed assertion `%s'\n", \
    35  message, file, line, expression ), abort(), 0 )
     51#define __WARN(expression, message, file, line)  \
     52(fprintf( stderr, "warning: " message "\n%s:%u: failed assertion `%s'\n", \
     53 file, line, expression ), 0 )
     54#define STICKYWARN(expression, message) \
     55((void)((expression) ? 0 : __WARN(#expression, message, __FILE__, __LINE__)))
    3656
    37 #ifdef DEBUGOUTPUT
    38 void deb_inc_level();
    39 void deb_dec_level();
    40 extern char * deb_level_msg;
    41 #define DEBINCLEVEL(stream,msg) \
    42 (stream << deb_level_msg << "entering << " << msg << " >>" << endl, deb_inc_level())
    43 #define DEBDECLEVEL(stream,msg) \
    44 (deb_dec_level(), stream << deb_level_msg << "leaving <<" << msg << " >>" << endl)
    45 #define DEBOUTSL(stream) \
    46 (stream << deb_level_msg, stream.flush())
    47 #define DEBOUT(stream,msg,object) \
    48 (stream << msg << object, stream.flush())
    49 #define DEBOUTLN(stream,msg,object) \
    50 (stream << deb_level_msg << msg << object << endl)
    51 #else
    52 #define DEBINCLEVEL(stream,msg)
    53 #define DEBDECLEVEL(stream,msg)
    54 #define DEBOUTSL(stream)
    55 #define DEBOUT(stream,msg,object)
    56 #define DEBOUTLN(stream,msg,object)
    57 #endif
     57#ifndef NOASSERT
     58#define ASSERT(expression, message) \
     59((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__)))
     60#define ASSERT1(expression, message, parameter1) \
     61((void)((expression) ? 0 : __ASSERT1(#expression, message, parameter1, __FILE__, __LINE__)))
     62
     63#define WARN(expression, message) \
     64((void)((expression) ? 0 : __WARN(#expression, message, __FILE__, __LINE__)))
     65
     66#define PVIRT_VOID(msg) \
     67{ fprintf( stderr, "pure method( " msg " ) called\n" ); abort(); }
     68#define PVIRT_INTCF(msg) \
     69{ fprintf( stderr, "pure method( " msg " ) called\n" ); abort(); return 0; }
     70#define PVIRT_BOOL(msg) \
     71{ fprintf( stderr, "pure method( " msg " ) called\n" ); abort(); return false; }
     72#define PVIRT_INT(msg) \
     73{ fprintf( stderr, "pure method( " msg " ) called\n" ); abort(); return 0; }
     74#define PVIRT_CHARCC(msg) \
     75{ fprintf( stderr, "pure method( " msg " ) called\n" ); abort(); return 0; }
     76#else /* NOASSERT */
     77#define ASSERT(expression, message)
     78#define ASSERT1(expression, message, parameter1)
     79
     80#define WARN(expression, message)
     81
     82#define PVIRT_VOID(msg) = 0
     83#define PVIRT_INTCF(msg) = 0
     84#define PVIRT_BOOL(msg) = 0
     85#define PVIRT_INT(msg) = 0
     86#define PVIRT_CHARCC(msg) = 0
     87#endif /* NOASSERT */
Note: See TracChangeset for help on using the changeset viewer.