home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !gcc / include / libscl / h / assert next >
Encoding:
Text File  |  2006-09-17  |  2.7 KB  |  71 lines

  1. /* assert.h standard header for the RISC OS SharedCLibrary.
  2.    Copyright (c) 1997-2005 Nick Burrett
  3.    All rights reserved.
  4.  
  5.    Redistribution and use in source and binary forms, with or without
  6.    modification, are permitted provided that the following conditions
  7.    are met:
  8.    1. Redistributions of source code must retain the above copyright
  9.       notice, this list of conditions and the following disclaimer.
  10.    2. Redistributions in binary form must reproduce the above copyright
  11.       notice, this list of conditions and the following disclaimer in the
  12.       documentation and/or other materials provided with the distribution.
  13.    3. The name of the author may not be used to endorse or promote products
  14.       derived from this software without specific prior written permission.
  15.  
  16.    THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17.    IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18.    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19.    IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  20.    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21.    NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22.    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23.    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24.    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25.    THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
  26.  
  27. /* Allow this file to be included multiple times
  28.    with different settings of NDEBUG.  */
  29. #undef assert
  30. #undef __assert
  31.  
  32. #ifdef NDEBUG
  33. #define assert(ignore) ((void) 0)
  34. #else
  35.  
  36. #ifndef __GNUC__
  37.  
  38. #define assert(expression)  \
  39.   ((void) ((expression) ? 0 : __assert (expression, __FILE__, __LINE__)))
  40.  
  41. #define __assert(expression, file, lineno)  \
  42.   (printf ("%s:%u: failed assertion\n", file, lineno),    \
  43.    abort (), 0)
  44.  
  45. #else
  46.  
  47. #if defined(__STDC__) || defined (__cplusplus)
  48.  
  49. #ifdef __cplusplus
  50. extern "C" void __assert (const char *, const char *, int);
  51. extern "C" int __assert2(const char *, const char *, const char *, int);
  52. #else
  53. extern void __assert(const char *, const char *, int);
  54. extern void __assert2(const char *, const char *, const char *, int);
  55. #endif
  56.  
  57.  
  58. #define assert(expression)  \
  59.   ((void) ((expression) ? 0 : __assert2 (#expression, __func__, __FILE__, __LINE__)))
  60.  
  61. #else /* no __STDC__ and not C++; i.e. -traditional.  */
  62.  
  63. extern void __assert(const char *, const char *, int);
  64.  
  65. #define assert(expression)  \
  66.   ((void) ((expression) ? 0 : __assert (#expression, __FILE__, __LINE__)))
  67.  
  68. #endif /* no __STDC__ and not C++; i.e. -traditional. */
  69. #endif /* no __GNU__; i.e., /bin/cc.  */
  70. #endif
  71.