1/*---------------------------------------------------------------------------* 2 * passert.h * 3 * * 4 * Copyright 2007, 2008 Nuance Communciations, Inc. * 5 * * 6 * Licensed under the Apache License, Version 2.0 (the 'License'); * 7 * you may not use this file except in compliance with the License. * 8 * * 9 * You may obtain a copy of the License at * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, software * 13 * distributed under the License is distributed on an 'AS IS' BASIS, * 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 15 * See the License for the specific language governing permissions and * 16 * limitations under the License. * 17 * * 18 *---------------------------------------------------------------------------*/ 19 20#ifndef PASSERT_H 21#define PASSERT_H 22 23 24 25/** 26 * @addtogroup ESR_PortableModule ESR_Portable API functions 27 * 28 * @{ 29 */ 30 31#if defined(_WIN32) || defined(POSIX) 32/** 33 * Checks if platform supports ASSERT. 34 */ 35#define HAS_ASSERT 36#endif 37 38#if defined(HAS_ASSERT) 39 40#include <assert.h> 41 42/** 43 * Portable assert(). 44 */ 45#define passert(exp) assert(exp) 46 47#elif defined(NDEBUG) 48 49#define passert(exp) 50 51#else 52 53/** 54* Portable assert(). 55*/ 56#define passert(exp) do { \ 57 if (!(exp)) \ 58 { \ 59 pfprintf(PSTDERR, __FILE__ "(%d): " #exp " failed.\n",__LINE__); \ 60 abort(); \ 61 } \ 62 } \ 63 while(0) 64 65#endif /* HAS_ASSERT */ 66 67/** 68 * @} 69 */ 70 71#endif 72