PhysX SDK 3.2 API Reference: PxAssert.h Source File

PhysX SDK 3.2 API

PxAssert.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you 
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and 
00007 // any modifications thereto. Any use, reproduction, disclosure, or 
00008 // distribution of this software and related documentation without an express 
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 // 
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2008-2012 NVIDIA Corporation. All rights reserved.
00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.  
00029 
00030 
00031 #ifndef PX_FOUNDATION_PX_ASSERT_H
00032 #define PX_FOUNDATION_PX_ASSERT_H
00033 
00037 #include "foundation/Px.h"
00038 
00039 #ifdef PX_WINDOWS
00040 
00041 #include <stdio.h>
00042 #include <crtdbg.h>
00043 
00044 extern void __debugbreak();
00045 #ifndef PX_DOXYGEN
00046 
00047 namespace physx
00048 {
00049 #endif
00050         PX_INLINE void PxAssert(const char* exp, const char* file, int line, bool* ignore)
00051         {
00052             //printf("Assertion failed: %s, file %s, line %d\n", exp, file, line);
00053 #ifdef _DEBUG
00054             if (ignore != NULL)
00055             {
00056                 int reportType = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_REPORT_MODE);
00057                 // PH: _CrtDbgReport returns -1 on error, 0 on 'ignore', 1 on 'retry'. Hitting 'abort' will terminate the process immediately.
00058                 // If the mode is not 'Window', we just always break.
00059                 *ignore = *ignore || ((reportType == _CRTDBG_MODE_WNDW) && (_CrtDbgReport(_CRT_ASSERT, file, line, NULL, "%s", exp) == 0));
00060             }
00061 
00062             if(ignore == NULL || !*ignore)
00063 #else
00064             PX_FORCE_PARAMETER_REFERENCE(exp);
00065             PX_FORCE_PARAMETER_REFERENCE(file);
00066             PX_FORCE_PARAMETER_REFERENCE(line);
00067             PX_FORCE_PARAMETER_REFERENCE(ignore);
00068 #endif
00069                 __debugbreak();
00070         }
00071 
00072 #ifndef PX_DOXYGEN
00073 } // namespace physx
00074 #endif
00075 
00076 #ifdef __CUDACC__
00077 #   define PX_ASSERT(exp)                   ((void)0)
00078 #   define PX_ALWAYS_ASSERT_MESSAGE(exp)    ((void)0)
00079 #else
00080 #ifndef NDEBUG
00081 #   define PX_ASSERT(exp)                   { static bool ignore = false; (void)( (!!(exp)) || (physx::PxAssert(#exp, __FILE__, __LINE__, &ignore), false) ); }
00082 #   define PX_ALWAYS_ASSERT_MESSAGE(exp)    { static bool ignore = false; (void)( (physx::PxAssert(#exp, __FILE__, __LINE__, &ignore), false) ); }
00083 #else
00084 #   define PX_ASSERT(exp)                   ((void)0)
00085 #   define PX_ALWAYS_ASSERT_MESSAGE(exp)    ((void)0)
00086 #endif
00087 #endif
00088 
00089 #elif defined(PX_PS3)
00090 #include "foundation/ps3/PxPS3Assert.h"
00091 #elif defined(PX_ANDROID)
00092 #include <assert.h>
00093 #ifndef NDEBUG
00094 #   include <android/log.h>
00095 #   define PX_ASSERT(exp)                   { if(!(exp)) __android_log_print(ANDROID_LOG_INFO, "PX_ASSERT", "%s: %s:%d\n", #exp, __FILE__, __LINE__); assert(exp); }
00096 #   define PX_ALWAYS_ASSERT_MESSAGE(exp)    { __android_log_print(ANDROID_LOG_INFO, "PX_ASSERT", "%s: %s:%d\n", #exp, __FILE__, __LINE__); assert((exp) && false); }
00097 #else
00098 #   define PX_ASSERT(exp)                   ((void)0)
00099 #   define PX_ALWAYS_ASSERT_MESSAGE(exp)    ((void)0)
00100 #endif
00101 #else // PX_WINDOWS, other platforms just forward to standard assert
00102 #include <assert.h>
00103 #define PX_ASSERT(exp)                      assert(exp)
00104 #define PX_ALWAYS_ASSERT_MESSAGE(exp)       assert((exp) && false)
00105 #endif
00106 
00107 
00108 #define PX_ALWAYS_ASSERT() PX_ASSERT(0)
00109 
00111 #endif // PX_FOUNDATION_PX_ASSERT_H


Copyright © 2008-2012 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com