Branimir Karadžić před 10 roky
rodič
revize
08ff290e0c
2 změnil soubory, kde provedl 8 přidání a 5 odebrání
  1. 6 3
      include/bx/error.h
  2. 2 2
      include/bx/readerwriter.h

+ 6 - 3
include/bx/error.h

@@ -14,10 +14,13 @@
 				_ptr->setError(_result,  "" _msg); \
 			BX_MACRO_BLOCK_END
 
+#define BX_ERROR_USE_TEMP_WHEN_NULL(_ptr) \
+			const bx::Error tmpError; /* It should not be used directly! */ \
+			_ptr = NULL == _ptr ? const_cast<bx::Error*>(&tmpError) : _ptr
+
 #define BX_ERROR_SCOPE(_ptr) \
-			const bx::Error tmpError /* It should not be used directly! */; \
-			_ptr = NULL == _ptr ? const_cast<bx::Error*>(&tmpError) : _ptr; \
-			bx::ErrorScope bxErrorScope(const_cast<bx::Error*>(&tmpError))
+			BX_ERROR_USE_TEMP_WHEN_NULL(_ptr); \
+			bx::ErrorScope bxErrorScope(const_cast<bx::Error*>(&tmpError) )
 
 #define BX_ERROR_RESULT(_err, _code) \
 			BX_STATIC_ASSERT(_code != 0, "ErrorCode 0 is reserved!"); \

+ 2 - 2
include/bx/readerwriter.h

@@ -224,7 +224,7 @@ namespace bx
 
 	inline bool open(FileReaderI* _reader, const char* _filePath, Error* _err = NULL)
 	{
-		BX_ERROR_SCOPE(_err);
+		BX_ERROR_USE_TEMP_WHEN_NULL(_err);
 		return _reader->open(_filePath, _err);
 	}
 
@@ -235,7 +235,7 @@ namespace bx
 
 	inline bool open(FileWriterI* _writer, const char* _filePath, bool _append = false, Error* _err = NULL)
 	{
-		BX_ERROR_SCOPE(_err);
+		BX_ERROR_USE_TEMP_WHEN_NULL(_err);
 		return _writer->open(_filePath, _append, _err);
 	}