1 | /**************************************************************************************** |
2 | |
3 | Copyright (C) 2015 Autodesk, Inc. |
4 | All rights reserved. |
5 | |
6 | Use of this software is subject to the terms of the Autodesk license agreement |
7 | provided at the time of installation or download, or which otherwise accompanies |
8 | this software in either electronic or hard copy form. |
9 | |
10 | ****************************************************************************************/ |
11 | |
12 | /** \file fbxdebug.h |
13 | * Debugging macros and functions. |
14 | * |
15 | * All macros and functions are removed in release builds. To enable asserts, a debug build is required as well |
16 | * as the environment variable "FBXSDK_ASSERT" set to 1 is also required. By default, assertions will pop-up |
17 | * a window. It is possible to disable the pop-up on the Windows platform by calling the following code: |
18 | * \code |
19 | * _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG); |
20 | * \endcode |
21 | */ |
22 | #ifndef _FBXSDK_CORE_ARCH_DEBUG_H_ |
23 | #define _FBXSDK_CORE_ARCH_DEBUG_H_ |
24 | |
25 | #include <fbxsdk/fbxsdk_def.h> |
26 | |
27 | #include <fbxsdk/fbxsdk_nsbegin.h> |
28 | |
29 | /** If this environment variable is set to 1, the FBX SDK will assert in debug builds */ |
30 | #define FBXSDK_ASSERT_ENVSTR "FBXSDK_ASSERT" |
31 | |
32 | /** The assertion procedure signature. If a different assertion procedure must be provided, it should have this signature. |
33 | * \param pFileName The file name where the assertion occurred. |
34 | * \param pFunctionName The function name where the assertion occurred. |
35 | * \param pLineNumber The line number in the file where the assertion occurred. |
36 | * \param pMessage The message to display when the assertion occurs. */ |
37 | typedef void (*FbxAssertProc)(const char* pFileName, const char* pFunctionName, const unsigned int pLineNumber, const char* pMessage); |
38 | |
39 | /** Change the procedure used when assertion occurs. |
40 | * \param pAssertProc The procedure to be called when assertions occurs. */ |
41 | FBXSDK_DLL void FbxAssertSetProc(FbxAssertProc pAssertProc); |
42 | |
43 | //! Change the procedure back to the default one. |
44 | FBXSDK_DLL void FbxAssertSetDefaultProc(); |
45 | |
46 | /***************************************************************************************************************************** |
47 | ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! ** |
48 | *****************************************************************************************************************************/ |
49 | #ifndef DOXYGEN_SHOULD_SKIP_THIS |
50 | |
51 | FBXSDK_DLL void _FbxAssert(const char* pFileName, const char* pFunctionName, const unsigned int pLineNumber, bool pFormat, const char* pMessage, ...); |
52 | FBXSDK_DLL void _FbxTrace(const char* pMessage, ...); |
53 | |
54 | #ifdef _DEBUG |
55 | template <bool x> struct FbxStaticAssertType; |
56 | template<> struct FbxStaticAssertType<true> {enum{value=1};}; |
57 | template<> struct FbxStaticAssertType<false> {enum{value=-1};}; |
58 | #define FBX_ASSERT(Condition) {if(!(Condition)){_FbxAssert(__FILE__,__FUNCTION__,__LINE__,false,#Condition);}} |
59 | #define FBX_ASSERT_MSG(Condition, Message, ...) {if(!(Condition)){_FbxAssert(__FILE__,__FUNCTION__,__LINE__,true,Message,##__VA_ARGS__);}} |
60 | #define FBX_ASSERT_NOW(Message, ...) _FbxAssert(__FILE__,__FUNCTION__,__LINE__,true,Message,##__VA_ARGS__); |
61 | #define FBX_ASSERT_RETURN(Condition) {if(!(Condition)){FBX_ASSERT_NOW(#Condition); return;}} |
62 | #define FBX_ASSERT_RETURN_VALUE(Condition, Value) {if(!(Condition)){FBX_ASSERT_NOW(#Condition); return Value;}} |
63 | #define FBX_ASSERT_STATIC(Condition) typedef char FbxBuildBreakIfFalse[FbxStaticAssertType<(bool)(Condition)>::value]; |
64 | #define FBX_TRACE(Message, ...) {_FbxTrace(Message,##__VA_ARGS__);} |
65 | #else |
66 | #define FBX_ASSERT(Condition) ((void)0) |
67 | #define FBX_ASSERT_MSG(Condition, Message, ...) ((void)0) |
68 | #define FBX_ASSERT_NOW(Message, ...) ((void)0) |
69 | #define FBX_ASSERT_RETURN(Condition) if(!(Condition)){return;} |
70 | #define FBX_ASSERT_RETURN_VALUE(Condition, Value) if(!(Condition)){return Value;} |
71 | #define FBX_ASSERT_STATIC(Condition) |
72 | #define FBX_TRACE(Message, ...) ((void)0) |
73 | #endif |
74 | |
75 | template<typename T> struct FbxIncompatibleWithArray{ enum {value = 0}; }; |
76 | |
77 | #define FBXSDK_INCOMPATIBLE_WITH_ARRAY_TEMPLATE(T)\ |
78 | struct FbxIncompatibleWithArray< T >{\ |
79 | union {\ |
80 | T t();\ |
81 | } catcherr;\ |
82 | enum {value = 1};} |
83 | |
84 | #define FBXSDK_INCOMPATIBLE_WITH_ARRAY(T)\ |
85 | template<> FBXSDK_INCOMPATIBLE_WITH_ARRAY_TEMPLATE(T) |
86 | |
87 | #define FBXSDK_IS_INCOMPATIBLE_WITH_ARRAY(T) ((bool) FbxIncompatibleWithArray<T>::value) |
88 | |
89 | #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/ |
90 | |
91 | #include <fbxsdk/fbxsdk_nsend.h> |
92 | |
93 | #endif /* _FBXSDK_CORE_ARCH_DEBUG_H_ */ |
94 | |