소스 검색

Fix typo in M3DWrapper.cpp

Don't use std::mutex if not supported.
Allow override to force it to be used if does in fact exist
Thank you CI
RichardTea 5 년 전
부모
커밋
45a96af9ac
1개의 변경된 파일11개의 추가작업 그리고 5개의 파일을 삭제
  1. 11 5
      code/M3D/M3DWrapper.cpp

+ 11 - 5
code/M3D/M3DWrapper.cpp

@@ -48,16 +48,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <assimp/IOStreamBuffer.h>
 #include <assimp/ai_assert.h>
 
-#if (__cplusplus >= 201103L) || (_MSC_VER >= 1915) || defined(AI_M3D_USE_STDMUTEX) // C++11 and MSVC that mostly supports it
-#define AI_M3D_USE_STDMUTEX
+#ifndef AI_M3D_USE_STDMUTEX
+#if (__cplusplus >= 201103L) || (_MSC_VER >= 1900) // C++11 and MSVC 2015 onwards
+#define AI_M3D_USE_STDMUTEX 1
+#else
+#define AI_M3D_USE_STDMUTEX 0
+#endif
+#endif
+
+#if AI_M3D_USE_STDMUTEX
 #include <mutex>
+std::mutex file_mutex;
 #endif
 
 // workaround: the M3D SDK expects a C callback, but we want to use Assimp::IOSystem to implement that
 // This makes it non-rentrant so lock a mutex (requires C++11)
 
-std::mutex file_mutex;
-
 extern "C" {
 void *m3dimporter_pIOHandler;
 
@@ -94,7 +100,7 @@ M3DWrapper::M3DWrapper() {
 }
 
 M3DWrapper::M3DWrapper(IOSystem *pIOHandler, const std::vector<unsigned char> &buffer) {
-#ifdef AI_M3D_USE_STDMUTEX
+#if AI_M3D_USE_STDMUTEX
 	// M3D is NOT thread-safe, so lock the global mutex
 	const std::lock_guard<std::mutex> lock(file_mutex);
 #endif