00001 /******************************************************************** 00002 * 00003 * Copyright (c) 1999-2008 ACCESS CO., LTD. All rights reserved. 00004 * Copyright 2006, 2007, ACCESS Systems Americas, Inc. All rights reserved. 00005 * 00006 * Version: MPL 1.1/LGPL 2.1 00007 * 00008 * The contents of this file are subject to the Mozilla Public License Version 00009 * 1.1 (the "License"); you may not use this file except in compliance with 00010 * the License. You may obtain a copy of the License at 00011 * http://www.mozilla.org/MPL/ 00012 * 00013 * Software distributed under the License is distributed on an "AS IS" basis, 00014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00015 * for the specific language governing rights and limitations under the 00016 * License. 00017 * 00018 * The Original Code is hikerproject.org code. 00019 * 00020 * The Initial Developer of the Original Code is ACCESS Systems Americas, Inc. 00021 * Portions created by the Initial Developer are 00022 * Copyright 2006-2007 the Initial Developer. All Rights Reserved. 00023 * 00024 * Contributor(s): 00025 * 00026 * Alternatively, the contents of this file may be used under the terms of 00027 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which 00028 * case the provisions of the LGPL are applicable instead of those above. 00029 * If you wish to allow use of your version of this file only under the terms 00030 * of the LGPL, and not to allow others to use your version of this file under 00031 * the terms of the MPL, indicate your decision by deleting the provisions 00032 * above and replace them with the notice and other provisions required by 00033 * the LGPL. If you do not delete the provisions above, a recipient may use 00034 * your version of this file under the terms of either the MPL or the LGPL. 00035 * You may obtain a copy of the LGPL at http://www.gnu.org/licenses/lgpl.txt. 00036 * 00037 ********************************************************************/ 00045 #ifndef ALP_FAIL_H_ 00046 #define ALP_FAIL_H_ 00047 00048 #include <stdarg.h> 00049 #include <hiker/config.h> 00050 #include <hiker/traces.h> 00051 00052 #ifdef __cplusplus 00053 extern "C" { 00054 #endif 00055 00056 // --------------------------------------------------------------------------- 00057 // I can't use ASSERT because the current meaning of ErrFatalDisplay is the 00058 // exact opposite of assert: it fails when the condition is true. 00059 // I want to keep the same logic to facilitate porting of existing code. 00060 00061 // --------------------------------------------------------------------------- 00074 void alp_fail_raise(const char* file, int line, const char* cond, const char* fmt, ...); 00075 00076 #if defined(WIN32) 00077 00078 // Visual C compiler does not support macros with variable arguments. 00079 // This handy feature is unfortunately not ANSI C++ either 00080 00081 00082 #else 00083 00084 // --------------------------------------------------------------------------- 00085 #if ALP_MODEL == ALP_MODEL_DEVELOPMENT 00086 00093 # define ALP_FAIL_FATAL_IF(cond, msg, ...) \ 00094 do { if (cond) { \ 00095 ALP_LOG(ALP_LOG_ERROR, msg, ## __VA_ARGS__); \ 00096 alp_fail_raise(__FILE__, __LINE__, #cond, msg, ## __VA_ARGS__); \ 00097 } } while (0) 00098 00105 # define ALP_FAIL_NON_FATAL_IF(cond, msg, ...) \ 00106 do { if (cond) { \ 00107 ALP_LOG(ALP_LOG_WARNING, msg, ## __VA_ARGS__); \ 00108 alp_fail_raise(__FILE__, __LINE__, #cond, msg, ## __VA_ARGS__); \ 00109 } } while (0) 00110 #else // ALP_MODEL == ALP_MODEL_PRODUCTION 00111 # define ALP_FAIL_FATAL_IF(cond, msg, ...) \ 00112 do { if (cond) { \ 00113 ALP_LOG(ALP_LOG_ERROR, msg, ## __VA_ARGS__); \ 00114 alp_fail_raise(__FILE__, __LINE__, #cond, msg, ## __VA_ARGS__); \ 00115 } } while (0) 00116 # define ALP_FAIL_NON_FATAL_IF(cond, msg, ...) \ 00117 do { if (cond) ALP_LOG(ALP_LOG_WARNING, msg, ## __VA_ARGS__); } while (0) 00118 #endif 00119 #endif 00120 00121 /* ------------------------------------------------------------------- */ 00122 #ifdef __cplusplus 00123 } 00124 #endif 00125 00126 #endif // ALP_FAIL_H_
Copyright © 1999-2008 ACCESS CO., LTD. All rights reserved.