00001 /******************************************************************** 00002 00003 Copyright 2006, ACCESS Systems Americas, Inc. All rights reserved. 00004 00005 The contents of this file are subject to the Mozilla Public License Version 00006 1.1 (the "License"); you may not use this file except in compliance with 00007 the License. You may obtain a copy of the License at 00008 http://www.mozilla.org/MPL/ 00009 00010 Software distributed under the License is distributed on an "AS IS" basis, 00011 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00012 for the specific language governing rights and limitations under the 00013 License. 00014 00015 The Original Code is the entire contents of this file. 00016 00017 The Initial Developer of the Original Code is ACCESS Systems Americas, Inc. 00018 00019 Portions created by ACCESS Systems Americas, Inc. are Copyright © 2006. All 00020 Rights Reserved. 00021 00022 Contributor(s): none. 00023 00024 ********************************************************************/ 00032 #ifndef ALP_FAIL_H_ 00033 #define ALP_FAIL_H_ 00034 00035 #include <stdarg.h> 00036 #include <hiker/config.h> 00037 00038 #ifdef __cplusplus 00039 extern "C" { 00040 #endif 00041 00042 // --------------------------------------------------------------------------- 00043 // I can't use ASSERT because the current meaning of ErrFatalDisplay is the 00044 // exact opposite of assert: it fails when the condition is true. 00045 // I want to keep the same logic to facilitate porting of existing code. 00046 00047 // --------------------------------------------------------------------------- 00048 void alp_fail_raise(const char* file, int line, const char* cond, const char* fmt, ...); 00049 00050 #if defined(WIN32) 00051 00052 // Visual C compiler does not support macros with variable arguments. 00053 // This handy feature is unfortunately not ANSI C++ either 00054 00055 00056 #else 00057 00058 // --------------------------------------------------------------------------- 00059 #if ALP_BUILD == ALP_BUILD_DEBUG 00060 # define ALP_FAIL_FATAL_IF(cond, msg, ...) \ 00061 do { if (cond) alp_fail_raise(__FILE__, __LINE__, #cond, msg, ## __VA_ARGS__); } while (0) 00062 # define ALP_FAIL_NON_FATAL_IF(cond, msg, ...) \ 00063 do { if (cond) alp_fail_raise(__FILE__, __LINE__, #cond, msg, ## __VA_ARGS__); } while (0) 00064 #else 00065 # define ALP_FAIL_FATAL_IF(cond, msg, ...) \ 00066 do { if (cond) alp_fail_raise(__FILE__, __LINE__, #cond, msg, ## __VA_ARGS__); } while (0) 00067 # define ALP_FAIL_NON_FATAL_IF(cond, msg, ...) 00068 #endif 00069 #endif 00070 00071 /* ------------------------------------------------------------------- */ 00072 #ifdef __cplusplus 00073 } 00074 #endif 00075 00076 #endif // ALP_FAIL_H_