Hogwarts Wand Docs: ../server/ac_assert.h

Wand Sourcecode: ../server/ac_assert.h

//
// ac_assert.h
//
// Copyright (C) 2006  Nathan (Acorn) Pooley
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License (gpl.txt) for more details. 
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
// 
// You can contact the author, Nathan (Acorn) Pooley, by writing
// to Nathan (Acorn) Pooley, 949 Buckeye Drive, Sunnyvale, CA  94086, USA
// or through the form at http://www.rawbw.com/~acorn/wand/feedback.html
//
//
#ifndef AC_ASSERT_H
#define AC_ASSERT_H
//

/*
#@DOC@ AC_ASSERT macro
*/

#ifdef __cplusplus
extern "C" {
#endif

//###########################################################################
//############################### NOTES #####################################
//###########################################################################
#define AC_ERROR_HELP
//
//
//  H   H   OOO   W   W        TTTTT   OOO        U   U   SSSS  EEEE
//  H   H  O   O  W W W          T    O   O       U   U  S      E
//  HHHHH  O   O  W W W          T    O   O       U   U   SSS   EEE
//  H   H  O   O  WWWWW          T    O   O       U   U      S  E
//  H   H   OOO    W W           T     OOO         UUU   SSSS   EEEEE
//
// AC_ASSERT(condition)     - statement
// AC_ASSERTX(condition)    - expression
//

//###########################################################################
//############################### DEFINES ###################################
//###########################################################################

#ifndef AC_DEBUG
#define AC_DEBUG    1
#endif

#ifdef __GNUC__
#define AC_ASSERT_FUNC  __FUNCTION__
#else
#define AC_ASSERT_FUNC  0
#endif

#define AC_ASSERT_FILE  __FILE__
#define AC_ASSERT_LINE  __LINE__

#if AC_DEBUG
#define AC_ASSERTX(cond) \
        ((cond)?0:acAssertFailed(#cond, AC_ASSERT_FUNC,  \
                                        AC_ASSERT_FILE,  \
                                        AC_ASSERT_LINE))
#define AC_ASSERT(cond)     do { (void)AC_ASSERTX(cond); } while(0)
#else
#define AC_ASSERTX(cond)    (0)
#define AC_ASSERT(cond)     do {} while(0)
#endif


//###########################################################################
//############################### TYPEDEFS ##################################
//###########################################################################

enum AcAssertModeEnum {
    AC_ASSERT_CRASH,
    AC_ASSERT_EXIT,
    AC_ASSERT_LOOP,
    AC_ASSERT_NO_CHANGE
} AcAssertMode;

//###########################################################################
//############################### INCLUDES ##################################
//###########################################################################

#include <stdio.h>

//###########################################################################
//############################### TYPEDEFS ##################################
//###########################################################################

typedef void (*AcAssertFuncType)(
                const char *cond, 
                const char *func, 
                const char *file, 
                int line);

//###########################################################################
//############################### GLOBALS ###################################
//###########################################################################

//###########################################################################
//############################### PROTOTYPES ################################
//###########################################################################

enum AcAssertModeEnum acAssertMode(enum AcAssertModeEnum mode);
AcAssertFuncType acAssertSetUserFunc(AcAssertFuncType func);
int acAssertCrash(void);
int acAssertFailed(
            const char *cond, 
            const char *func, 
            const char *file, 
            int         line);

#ifdef __cplusplus
}
#endif  /* C++ */
#endif  /* _AC_ASSERT_H */

This file Copyright (C) 2006 by Nathan (Acorn) Pooley
Go to TOP Wand page
Go to Acorn's personal webpage
Go to Hogwarts website: www.gotohogwarts.com
Snout: www.snout.org/game
Gadgets of Justice Unlimited
Snout GC (Wiki)
Snout Wiki
File created by do_doc at Wed May 30 03:30:04 PDT 2007