Adaptagrams
assertions.h
1 /*
2  * vim: ts=4 sw=4 et tw=0 wm=0
3  *
4  * libavoid - Fast, Incremental, Object-avoiding Line Router
5  *
6  * Copyright (C) 2009 Monash University
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  * See the file LICENSE.LGPL distributed with the library.
13  *
14  * Licensees holding a valid commercial license may use this file in
15  * accordance with the commercial license agreement provided with the
16  * library.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21  *
22  * Author(s): Michael Wybrow
23 */
24 
25 #ifndef AVOID_ASSERTIONS_H
26 #define AVOID_ASSERTIONS_H
27 
28 #define COLA_UNUSED(expr) do { (void)(expr); } while (0)
29 
30 #ifdef NDEBUG
31 
32  #define COLA_ASSERT(expr) static_cast<void>(0)
33 
34 #else // Not NDEBUG
35 
36  #ifdef _MSC_VER
37  // Compiling with Microsoft Visual C++ compiler
38 
39  // Prevent inclusion of min and max macros.
40  #define NOMINMAX
41 
42  #include <afx.h>
43  #define COLA_ASSERT(expr) ASSERT(expr)
44 
45  #elif defined(USE_ASSERT_EXCEPTIONS)
46 
47  #include "libvpsc/assertions.h"
48 
49  #else
50 
51  #include <cassert>
52  #define COLA_ASSERT(expr) assert(expr)
53 
54  #endif
55 
56 #endif
57 
58 
59 #endif // AVOID_ASSERTIONS_H
60