fbxdebug.h 4.6 KB

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