Visualization LibraryA lightweight C++ OpenGL middleware for 2D/3D graphics |
[Home] [Tutorials] [All Classes] [Grouped Classes] |
00001 /**************************************************************************************/ 00002 /* */ 00003 /* Visualization Library */ 00004 /* http://www.visualizationlibrary.org */ 00005 /* */ 00006 /* Copyright (c) 2005-2010, Michele Bosi */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without modification, */ 00010 /* are permitted provided that the following conditions are met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, this */ 00013 /* list of conditions and the following disclaimer. */ 00014 /* */ 00015 /* - Redistributions in binary form must reproduce the above copyright notice, this */ 00016 /* list of conditions and the following disclaimer in the documentation and/or */ 00017 /* other materials provided with the distribution. */ 00018 /* */ 00019 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */ 00020 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */ 00021 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ 00022 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */ 00023 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ 00024 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */ 00025 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ 00026 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 00027 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ 00028 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00029 /* */ 00030 /**************************************************************************************/ 00031 00032 #ifndef CHECK_INCLUDED 00033 #define CHECK_INCLUDED 00034 00035 #include <vlCore/config.hpp> 00036 00037 // Required for IsDebuggerPresent() 00038 #if defined(VL_PLATFORM_WINDOWS) 00039 #ifndef WIN32_LEAN_AND_MEAN 00040 #define WIN32_LEAN_AND_MEAN 1 00041 #endif 00042 #ifndef NOMINMAX 00043 #define NOMINMAX 00044 #endif 00045 #include <windows.h> 00046 #endif 00047 00048 #if defined(__GNUG__) || defined(__MINGW32__) 00049 #include <cstdio> 00050 #endif 00051 00052 namespace vl 00053 { 00054 VLCORE_EXPORT void log_failed_check(const char*, const char*, int); 00055 00056 VLCORE_EXPORT void abort_vl(); 00057 00058 // Compile-time check 00059 #define VL_COMPILE_TIME_CHECK( expr ) typedef char compile_time_assert[ (expr) ? 1 : -1 ]; 00060 00061 #if defined(_DEBUG) || !defined(NDEBUG) || VL_FORCE_CHECKS == 1 00062 00063 // Visual Studio 00064 #if defined(_MSC_VER) 00065 #define VL_TRAP() { if (IsDebuggerPresent()) { __debugbreak(); } else ::vl::abort_vl(); } 00066 // GNU GCC 00067 #elif defined(__GNUG__) || defined(__MINGW32__) 00068 #define VL_TRAP() { fflush(stdout); fflush(stderr); asm("int $0x3"); } 00069 #else 00070 #define VL_TRAP() { ::vl::abort_vl(); } 00071 #endif 00072 00073 #define VL_CHECK(expr) { if(!(expr)) { ::vl::log_failed_check(#expr,__FILE__,__LINE__); VL_TRAP() } } 00074 #define VL_WARN(expr) { if(!(expr)) { ::vl::log_failed_check(#expr,__FILE__,__LINE__); } } 00075 00076 // MSDN checked iterators 00077 // #define _SECURE_SCL 1 00078 #else 00079 #define VL_WARN(expr) {} 00080 #define VL_CHECK(expr) {} 00081 #define VL_TRAP() {} 00082 00083 // MSDN checked iterators 00084 // #define _SECURE_SCL 0 00085 #endif 00086 } 00087 00088 #endif