Browse Source

Use EA_DISABLE_VC_WARNING instead of raw pragmas

Rafaël Kooi 6 years ago
parent
commit
e208999668

+ 2 - 2
include/eathread/eathread.h

@@ -740,9 +740,9 @@ namespace EA
 	#define EAThreadGetUniqueId(dest) dest = (EA::Thread::ThreadUniqueId)(uintptr_t)__readfsdword(0x18)
 
 #elif defined(EA_COMPILER_MSVC) && defined(EA_PROCESSOR_X86_64)
-	#pragma warning(push, 0)
+	EA_DISABLE_ALL_VC_WARNINGS()
 	#include <intrin.h>
-	#pragma warning(pop)
+	EA_RESTORE_ALL_VC_WARNINGS()
 	#define EAThreadGetUniqueId(dest) dest = (EA::Thread::ThreadUniqueId)(uintptr_t)__readgsqword(0x30)
 	// Could also use dest = (EA::Thread::ThreadUniqueId)NtCurrentTeb(), but that would require #including <windows.h>, which is very heavy.
 

+ 4 - 7
include/eathread/eathread_atomic.h

@@ -414,10 +414,9 @@ namespace EA
 		#endif
 
 
-		#ifdef EA_COMPILER_MSVC              // VC++ yields spurious warnings about void* being cast to an integer type and vice-versa.
-			#pragma warning(push)        // These warnings are baseless because we check for platform pointer size above.
-			#pragma warning(disable: 4311 4312 4251)
-		#endif
+		// VC++ yields spurious warnings about void* being cast to an integer type and vice-versa.
+		// These warnings are baseless because we check for platform pointer size above.
+		EA_DISABLE_VC_WARNING(4311 4312 4251)
 
 
 		/// class AtomicPointer
@@ -455,9 +454,7 @@ namespace EA
 		};
 
 
-		#ifdef EA_COMPILER_MSVC
-			#pragma warning(pop)
-		#endif
+		EA_RESTORE_VC_WARNING()
 
 	} // namespace Thread
 

+ 3 - 4
include/eathread/eathread_barrier.h

@@ -24,8 +24,7 @@
 	// These templates cannot be instantiated outside of the DLL. If you try, a
 	// link error will result. This compiler warning is intended to notify users
 	// of this.
-	#pragma warning(push)
-	#pragma warning(disable: 4251)
+	EA_DISABLE_VC_WARNING(4251)
 #endif
 
 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
@@ -228,8 +227,8 @@ namespace EA
 
 
 #if defined(EA_DLL) && defined(EA_COMPILER_MSVC)
-   // re-enable warning(s) disabled above.
-   #pragma warning(pop)
+	// re-enable warning(s) disabled above.
+	EA_RESTORE_VC_WARNING()
 #endif
 
 

+ 2 - 13
include/eathread/eathread_condition.h

@@ -29,8 +29,7 @@
 	// These templates cannot be instantiated outside of the DLL. If you try, a
 	// link error will result. This compiler warning is intended to notify users
 	// of this.
-	#pragma warning(push)
-	#pragma warning(disable: 4251)
+	EA_DISABLE_VC_WARNING(4251)
 #endif
 
 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
@@ -236,19 +235,9 @@ namespace EA
 
 #if defined(EA_DLL) && defined(EA_COMPILER_MSVC)
 	// re-enable warning 4251 (it's a level-1 warning and should not be suppressed globally)
-	#pragma warning(pop)
+	EA_RESTORE_VC_WARNING()
 #endif
 
 
 
 #endif // EATHREAD_EATHREAD_CONDITION_H
-
-
-
-
-
-
-
-
-
-

+ 2 - 3
include/eathread/eathread_pool.h

@@ -33,8 +33,7 @@
 	// These templates cannot be instantiated outside of the DLL. If you try, a
 	// link error will result. This compiler warning is intended to notify users
 	// of this.
-	#pragma warning(push)
-	#pragma warning(disable: 4251)
+	EA_DISABLE_VC_WARNING(4251)
 #endif
 
 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
@@ -284,7 +283,7 @@ namespace EA
 
 #if defined(EA_DLL) && defined(EA_COMPILER_MSVC)
 	// re-enable warning 4251 (it's a level-1 warning and should not be suppressed globally)
-	#pragma warning(pop)
+	EA_RESTORE_VC_WARNING()
 #endif
 
 

+ 7 - 10
include/eathread/eathread_rwmutex_ip.h

@@ -18,20 +18,19 @@
 #include <eathread/eathread.h>
 #include <new>
 #if EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP)
-	#pragma warning(push, 0)
+	EA_DISABLE_ALL_VC_WARNINGS()
 	#include <Windows.h>
-	#pragma warning(pop)
+	EA_RESTORE_ALL_VC_WARNINGS()
 #endif
 
 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
 	#pragma once // Some compilers (e.g. VC++) benefit significantly from using this. We've measured 3-4% build speed improvements in apps as a result.
 #endif
 
-#ifdef EA_COMPILER_MSVC
-	#pragma warning(push)           // We have to be careful about disabling this warning. Sometimes the warning is meaningful; sometimes it isn't.
-	#pragma warning(disable: 4251)  // class (some template) needs to have dll-interface to be used by clients.
-	#pragma warning(disable: 6054)  // String 'argument 2' might not be zero-terminated
-#endif
+// We have to be careful about disabling this warning. Sometimes the warning is meaningful; sometimes it isn't.
+// 4251: class (some template) needs to have dll-interface to be used by clients.
+// 6054: String 'argument 2' might not be zero-terminated
+EA_DISABLE_VC_WARNING(4251 6054)
 
 namespace EA
 {
@@ -411,8 +410,6 @@ namespace EA
 
 } // namespace EA
 
-#ifdef EA_COMPILER_MSVC
-	#pragma warning(pop)
-#endif
+EA_RESTORE_VC_WARNING()
 
 #endif // EATHREAD_EATHREAD_RWMUTEX_IP_H

+ 2 - 7
include/eathread/eathread_rwspinlock.h

@@ -17,10 +17,7 @@
 #include <eathread/eathread_atomic.h>
 #include <new>
 
-#ifdef EA_COMPILER_MSVC
-	 #pragma warning(push)
-	 #pragma warning(disable: 4100) // (Compiler claims pRWSpinLock is unreferenced)
-#endif
+EA_DISABLE_VC_WARNING(4100) // (Compiler claims pRWSpinLock is unreferenced)
 
 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
 	#pragma once // Some compilers (e.g. VC++) benefit significantly from using this. We've measured 3-4% build speed improvements in apps as a result.
@@ -391,8 +388,6 @@ namespace EA
 
 } // namespace EA
 
-#ifdef EA_COMPILER_MSVC
-	#pragma warning(pop)
-#endif
+EA_RESTORE_VC_WARNING()
 
 #endif // EATHREAD_EATHREAD_RWSPINLOCK_H

+ 2 - 7
include/eathread/eathread_rwspinlockw.h

@@ -18,10 +18,7 @@
 #include <eathread/eathread_atomic.h>
 #include <new>
 
-#ifdef EA_COMPILER_MSVC
-	#pragma warning(push)
-	#pragma warning(disable: 4100) // (Compiler claims pRWSpinLockW is unreferenced)
-#endif
+EA_DISABLE_VC_WARNING(4100) // (Compiler claims pRWSpinLockW is unreferenced)
 
 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
 	#pragma once // Some compilers (e.g. VC++) benefit significantly from using this. We've measured 3-4% build speed improvements in apps as a result.
@@ -428,8 +425,6 @@ namespace EA
 
 } // namespace EA
 
-#ifdef EA_COMPILER_MSVC
-	#pragma warning(pop)
-#endif
+EA_RESTORE_VC_WARNING()
 
 #endif // Header include guard

+ 2 - 9
include/eathread/eathread_thread.h

@@ -27,8 +27,7 @@ EA_RESTORE_ALL_VC_WARNINGS()
 	// These templates cannot be instantiated outside of the DLL. If you try, a
 	// link error will result. This compiler warning is intended to notify users
 	// of this.
-	#pragma warning(push)
-	#pragma warning(disable: 4251)
+	EA_DISABLE_VC_WARNING(4251)
 #endif
 
 
@@ -789,14 +788,8 @@ namespace EA
 
 #if defined(EA_DLL) && defined(EA_COMPILER_MSVC)
 	// re-enable warning 4251 (it's a level-1 warning and should not be suppressed globally)
-	#pragma warning(pop)
+	EA_RESTORE_VC_WARNING()
 #endif
 
 
 #endif // EATHREAD_EATHREAD_THREAD_H
-
-
-
-
-
-

+ 4 - 8
include/eathread/x86-64/eathread_atomic_x86-64.h

@@ -20,15 +20,13 @@
 
 
 #ifdef EA_COMPILER_MSVC
-	#pragma warning(push, 0)
+	EA_DISABLE_ALL_VC_WARNINGS()
 	#include <math.h>   // VS2008 has an acknowledged bug that requires math.h (and possibly also string.h) to be #included before intrin.h.
 	#include <intrin.h>
-	#pragma warning(pop)
-
-	#pragma warning(push)
-	#pragma warning(disable: 4146)  // unary minus operator applied to unsigned type, result still unsigned
+	EA_RESTORE_ALL_VC_WARNINGS()
 #endif
 
+EA_DISABLE_VC_WARNING(4146)  // unary minus operator applied to unsigned type, result still unsigned
 
 #if defined(EA_PROCESSOR_X86_64)
 
@@ -440,8 +438,6 @@
 
 #endif // EA_PROCESSOR_X86_64
 
-#ifdef EA_COMPILER_MSVC
-	 #pragma warning(pop)
-#endif
+EA_RESTORE_VC_WARNING()
 
 #endif // EATHREAD_X86_64_EATHREAD_ATOMIC_X86_64_H

+ 2 - 2
include/eathread/x86-64/eathread_sync_x86-64.h

@@ -24,10 +24,10 @@
 	#define EA_THREAD_SYNC_IMPLEMENTED
 
 	#ifdef EA_COMPILER_MSVC
-		#pragma warning(push, 0)
+		EA_DISABLE_ALL_VC_WARNINGS()
 		#include <math.h>   // VS2008 has an acknowledged bug that requires math.h (and possibly also string.h) to be #included before intrin.h.
 		#include <intrin.h>
-		#pragma warning(pop)
+		EA_RESTORE_ALL_VC_WARNINGS()
 	#endif
 
 	// By default, we define EA_TARGET_SMP to be true. The reason for this is that most 

+ 4 - 25
include/eathread/x86/eathread_atomic_x86.h

@@ -19,13 +19,9 @@
 #include <stddef.h>
 #include <eathread/internal/eathread_atomic_standalone.h>
 
-
-#ifdef EA_COMPILER_MSVC
-	 #pragma warning(push)
-	 #pragma warning(disable: 4146)  // unary minus operator applied to unsigned type, result still unsigned
-	 #pragma warning(disable: 4339)  // use of undefined type detected in CLR meta-data
-#endif
-
+// 4146: unary minus operator applied to unsigned type, result still unsigned
+// 4339: use of undefined type detected in CLR meta-data
+EA_DISABLE_VC_WARNING(4146 4339)
 
 // This is required for Windows Phone (ARM) because we are temporarily not using
 // CPP11 style atomics and we are depending on the MSVC intrinics.
@@ -720,23 +716,6 @@
 
 #endif // EA_PROCESSOR_X86
 
-
-#ifdef EA_COMPILER_MSVC
-	 #pragma warning(pop)
-#endif
-
+EA_RESTORE_VC_WARNING()
 
 #endif // EATHREAD_X86_EATHREAD_ATOMIC_X86_H
-
-
-
-
-
-
-
-
-
-
-
-
-

+ 2 - 2
source/arm/eathread_callstack_arm.cpp

@@ -13,10 +13,10 @@
 #endif
 
 #if defined(EA_PLATFORM_WINDOWS) && EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP)
-	#pragma warning(push, 0)
+	EA_DISABLE_ALL_VC_WARNINGS()
 	#include <Windows.h>
 	#include <winternl.h>
-	#pragma warning(pop)
+	EA_RESTORE_ALL_VC_WARNINGS()
 #endif
 
 #if defined(EA_PLATFORM_UNIX)

+ 4 - 4
source/eathread_futex.cpp

@@ -222,9 +222,9 @@
 
 #elif defined(EA_PLATFORM_MICROSOFT) && !EA_USE_CPP11_CONCURRENCY && !EATHREAD_MANUAL_FUTEX_ENABLED
 
-	#pragma warning(push, 0)
+	EA_DISABLE_ALL_VC_WARNINGS()
 	#include <Windows.h>
-	#pragma warning(pop)
+	EA_RESTORE_ALL_VC_WARNINGS()
 
 	// Validate what we assume to be invariants.
 	EAT_COMPILETIME_ASSERT(sizeof(CRITICAL_SECTION) <= (EA::Thread::FUTEX_PLATFORM_DATA_SIZE / sizeof(uint64_t) * sizeof(uint64_t)));
@@ -243,9 +243,9 @@
 #elif defined(EA_PLATFORM_MICROSOFT) && EATHREAD_MANUAL_FUTEX_ENABLED
 
 	#if defined(EA_PLATFORM_WINDOWS)
-		#pragma warning(push, 0)
+		EA_DISABLE_ALL_VC_WARNINGS()
 		#include <Windows.h>
-		#pragma warning(pop)
+		EA_RESTORE_ALL_VC_WARNINGS()
 	#endif
 
 	void EA::Thread::Futex::CreateFSemaphore()

+ 7 - 20
source/eathread_pool.cpp

@@ -8,13 +8,10 @@
 #include <string.h>
 #include <new>
 
-#if defined(EA_COMPILER_MSVC)
-	#pragma warning(push)
-	#pragma warning(disable: 6011) // Dereferencing NULL pointer 'gpAllocator'
-	#pragma warning(disable: 6211) // Leaking memory 'pThreadInfo' due to an exception.
-	#pragma warning(disable: 6326) // Potential comparison of a constant with another constant
-#endif
-
+// 6011: Dereferencing NULL pointer 'gpAllocator'
+// 6211: Leaking memory 'pThreadInfo' due to an exception.
+// 6326: Potential comparison of a constant with another constant
+EA_DISABLE_VC_WARNING(6011 6211 6326)
 
 namespace EA
 {
@@ -91,10 +88,7 @@ EA::Thread::ThreadPool::~ThreadPool()
 }
 
 
-#ifdef EA_COMPILER_MSVC
-	#pragma warning(push)
-	#pragma warning(disable: 4296 4706) // '>=' : expression is always true and assignment within conditional expression (in the assert)
-#endif
+EA_DISABLE_VC_WARNING(4296 4706) // '>=' : expression is always true and assignment within conditional expression (in the assert)
 
 
 #if EAT_ASSERT_ENABLED
@@ -169,9 +163,7 @@ bool EA::Thread::ThreadPool::Init(const ThreadPoolParameters* pThreadPoolParamet
 }
 
 
-#ifdef EA_COMPILER_MSVC
-	#pragma warning(pop)
-#endif
+EA_RESTORE_VC_WARNING() // 4296 4706
 
 
 bool EA::Thread::ThreadPool::Shutdown(JobWait jobWait, const ThreadTime& timeoutAbsolute)
@@ -703,9 +695,4 @@ void EA::Thread::ThreadPoolFactory::DestructThreadPool(EA::Thread::ThreadPool* p
 	pThreadPool->~ThreadPool();
 }
 
-
-#if defined(EA_COMPILER_MSVC)
-	#pragma warning(pop)
-#endif
-
-
+EA_RESTORE_VC_WARNING()

+ 5 - 12
source/eathread_rwmutex.cpp

@@ -1,13 +1,11 @@
-///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 // Copyright (c) Electronic Arts Inc. All rights reserved.
 ///////////////////////////////////////////////////////////////////////////////
 
 #include <EABase/eabase.h>
 
-#if defined(EA_COMPILER_MSVC)
-	#pragma warning(disable: 4985)  // 'ceil': attributes not present on previous declaration.1>    C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\intrin.h(142) : see declaration of 'ceil'
-#endif
 
+EA_DISABLE_VC_WARNING(4985)  // 'ceil': attributes not present on previous declaration.1>    C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\intrin.h(142) : see declaration of 'ceil'
 
 #include <eathread/internal/config.h>
 #include <eathread/eathread_rwmutex.h>
@@ -15,10 +13,7 @@
 #include <new> // include new for placement new operator
 #include <string.h>
 
-#ifdef EA_COMPILER_MSVC
-	#pragma warning(disable : 4996) // This function or variable may be unsafe / deprecated.
-#endif
-
+EA_DISABLE_VC_WARNING(4996) // This function or variable may be unsafe / deprecated.
 
 	EARWMutexData::EARWMutexData()
 	  : mnReadWaiters(0), 
@@ -259,7 +254,5 @@ void EA::Thread::RWMutexFactory::DestructRWMutex(EA::Thread::RWMutex* pRWMutex)
 	pRWMutex->~RWMutex();
 }
 
-
-
-
-
+EA_RESTORE_VC_WARNING() // 4996
+EA_RESTORE_VC_WARNING() // 4985

+ 4 - 8
source/eathread_storage.cpp

@@ -47,9 +47,9 @@ EA_RESTORE_VC_WARNING()
 	#if defined(EA_PLATFORM_UNIX)
 		#include <unistd.h>
 	#elif defined(EA_PLATFORM_WINDOWS)
-		#pragma warning(push, 0)
+		EA_DISABLE_ALL_VC_WARNINGS()
 		#include <Windows.h>
-		#pragma warning(pop)
+		EA_RESTORE_ALL_VC_WARNINGS()
 	#endif
 
 	EA::Thread::ThreadLocalStorage::ThreadLocalStorage()
@@ -84,9 +84,9 @@ EA_RESTORE_VC_WARNING()
 
 
 #elif defined(EA_PLATFORM_MICROSOFT) && !defined(EA_PLATFORM_WINDOWS_PHONE) && !(defined(EA_PLATFORM_WINDOWS) && !EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP)) 
-		#pragma warning(push, 0)
+		EA_DISABLE_ALL_VC_WARNINGS()
 		#include <Windows.h>
-		#pragma warning(pop)
+		EA_RESTORE_ALL_VC_WARNINGS()
 
 	EA::Thread::ThreadLocalStorage::ThreadLocalStorage()
 		: mTLSData(TlsAlloc())
@@ -348,7 +348,3 @@ void EA::Thread::ThreadLocalStorageFactory::DestructThreadLocalStorage(EA::Threa
 
 #undef OSEnableInterrupts   
 #undef OSDisableInterrupts
-
-
-
-

+ 2 - 7
source/null/eathread_callstack_null.cpp

@@ -7,11 +7,7 @@
 #include <eathread/eathread_storage.h>
 #include <string.h>
 
-
-#if defined(EA_COMPILER_MSVC)
-	#pragma warning(disable: 4172) // returning address of local variable or temporary
-#endif
-
+EA_DISABLE_VC_WARNING(4172) // returning address of local variable or temporary
 
 namespace EA
 {
@@ -118,5 +114,4 @@ EATHREADLIB_API void* GetStackLimit()
 } // namespace Thread
 } // namespace EA
 
-
-
+EA_RESTORE_VC_WARNING()

+ 5 - 11
source/pc/eathread_callstack_win32.cpp

@@ -9,21 +9,14 @@
 
 #if defined(EA_PLATFORM_WIN32) && EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP) // The following only works on Win32 and not Win64.
 
-#if defined(EA_COMPILER_MSVC)
-	#pragma warning(push, 0)
-#endif
-
+EA_DISABLE_ALL_VC_WARNINGS()
 #include <Windows.h>
 #include <DbgHelp.h>
 #include <stdio.h>
+EA_RESTORE_ALL_VC_WARNINGS()
 
-#if defined(EA_COMPILER_MSVC)
-	#pragma warning(pop)
-#endif
-
-
+EA_DISABLE_VC_WARNING(4740)      // flow in or out of inline asm code suppresses global optimization
 #ifdef EA_COMPILER_MSVC
-	#pragma warning(disable: 4740)      // flow in or out of inline asm code suppresses global optimization
 	#pragma comment(lib, "dbghelp.lib")
 	#pragma comment(lib, "psapi.lib")
 #endif
@@ -532,5 +525,6 @@ EATHREADLIB_API size_t GetCallstack(void* pReturnAddressArray[], size_t nReturnA
 } // namespace Thread
 } // namespace EA
 
-#endif // defined(EA_PLATFORM_WIN32)
+EA_RESTORE_VC_WARNING()
 
+#endif // defined(EA_PLATFORM_WIN32)

+ 2 - 2
source/pc/eathread_callstack_win64.cpp

@@ -14,7 +14,7 @@
 #endif
 
 #ifdef EA_COMPILER_MSVC
-	#pragma warning(push, 0)
+	EA_DISABLE_ALL_VC_WARNINGS()
 	#include <Windows.h>
 	#include <math.h>       // VS2008 has an acknowledged bug that requires math.h (and possibly also string.h) to be #included before intrin.h.
 	#include <intrin.h>
@@ -26,7 +26,7 @@
 		extern "C" NTSYSAPI PEXCEPTION_ROUTINE NTAPI RtlVirtualUnwind(DWORD, DWORD64, DWORD64, PRUNTIME_FUNCTION, PCONTEXT, PVOID*, PDWORD64, PKNONVOLATILE_CONTEXT_POINTERS);
 		extern "C" WINBASEAPI DWORD WINAPI GetModuleFileNameA(HMODULE, LPSTR, DWORD);
 	#endif
-	#pragma warning(pop)
+	EA_RESTORE_ALL_VC_WARNINGS()
 #else
 	#include <Windows.h>
 	#include <winternl.h>

+ 2 - 3
source/pc/eathread_mutex_pc.cpp

@@ -115,8 +115,7 @@
 
 
 
-	#pragma warning(push)
-	#pragma warning(disable: 4706) // disable warning about assignment within a conditional expression
+	EA_DISABLE_VC_WARNING(4706) // disable warning about assignment within a conditional expression
 
 	int EA::Thread::Mutex::Lock(const ThreadTime& timeoutAbsolute)
 	{
@@ -162,7 +161,7 @@
 		return ++mMutexData.mnLockCount; // This is safe to do because we have the lock.
 	}
 
-	#pragma warning(pop)
+	EA_RESTORE_VC_WARNING()
 
 
 

+ 2 - 3
source/pc/eathread_pc.cpp

@@ -676,8 +676,7 @@ namespace Internal {
 
 		jmp_buf jmpbuf;
 
-		__pragma(warning(push))
-		__pragma(warning(disable : 4611))
+		EA_DISABLE_VC_WARNING(4611)
 		if (!setjmp(jmpbuf))
 		{
 			ThreadNameInfo threadNameInfo = {0x1000, pName, threadId, 0};
@@ -685,7 +684,7 @@ namespace Internal {
 			__except (GetExceptionCode() == 0x406D1388 ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { }
 			longjmp(jmpbuf, 1);
 		}
-		__pragma(warning(pop))
+		EA_RESTORE_VC_WARNING()
 	}
 
 	void SetThreadName(EAThreadDynamicData* pTDD, const char* pName)

+ 13 - 14
source/pc/eathread_thread_pc.cpp

@@ -10,7 +10,7 @@
 #include "eathread/eathread_thread.h"
 #include "eathread/internal/eathread_global.h"
 
-#if EA_COMPILER_VERSION >= 1900 // VS2015+
+#if defined(EA_COMPILER_MSVC) && EA_COMPILER_VERSION >= 1900 // VS2015+
 // required for windows.h that has mismatch that is included in this file
 	EA_DISABLE_VC_WARNING(5031 5032)// #pragma warning(pop): likely mismatch, popping warning state pushed in different file / detected #pragma warning(push) with no corresponding
 #endif
@@ -43,10 +43,6 @@ EA_DISABLE_VC_WARNING(6312 6322)
 
 
 	#ifdef EA_COMPILER_MSVC
-		#ifndef EATHREAD_INIT_SEG_DEFINED
-			#define EATHREAD_INIT_SEG_DEFINED 
-		#endif
-
 		// We are changing the initalization ordering here because in bulkbuild tool builds the initialization 
 		// order of globals changes and causes a crash when we attempt to lock the Mutex guarding access
 		// of the EAThreadDynamicData objects.  The code attempts to lock a mutex that has been destructed
@@ -55,9 +51,11 @@ EA_DISABLE_VC_WARNING(6312 6322)
 		//
 		#ifndef EATHREAD_INIT_SEG_DEFINED
 			#define EATHREAD_INIT_SEG_DEFINED 
-			#pragma warning(disable: 4075) // warning C4075: initializers put in unrecognized initialization area
-			#pragma warning(disable: 4073) //warning C4073: initializers put in library initialization area
+			// warning C4075: initializers put in unrecognized initialization area
+			//warning C4073: initializers put in library initialization area
+			EA_DISABLE_VC_WARNING(4075 4073)
 			#pragma init_seg(lib)
+			#define WARNING_INIT_SEG_PUSHED
 		#endif
 	#endif
 
@@ -820,14 +818,15 @@ EA_DISABLE_VC_WARNING(6312 6322)
 			EA::Thread::Internal::SetThreadName(mThreadData.mpData, pName);
 	}
 
-
+	#ifdef WARNING_INIT_SEG_PUSHED
+		#undef WARNING_INIT_SEG_PUSHED
+		EA_RESTORE_VC_WARNING() // 4073 4075
+	#endif
 #endif // EA_PLATFORM_MICROSOFT
 
-EA_RESTORE_VC_WARNING()
+EA_RESTORE_VC_WARNING() // 6312 6322
 
-#if EA_COMPILER_VERSION >= 1900 // VS2015+
-	EA_RESTORE_VC_WARNING()// #pragma warning(pop): likely mismatch, popping warning state pushed in different file / detected #pragma warning(push) with no corresponding
+#if defined(EA_COMPILER_MSVC) && EA_COMPILER_VERSION >= 1900 // VS2015+
+	EA_RESTORE_VC_WARNING() // 5031 5032
+	// #pragma warning(pop): likely mismatch, popping warning state pushed in different file / detected #pragma warning(push) with no corresponding
 #endif
-
-
-

+ 2 - 2
source/unix/eathread_barrier_unix.cpp

@@ -15,9 +15,9 @@
 	#include <string.h>
 	#include <new>
 	#ifdef EA_PLATFORM_WINDOWS
-		#pragma warning(push, 0)
+		EA_DISABLE_ALL_VC_WARNINGS()
 		#include <Windows.h> // Presumably we are using pthreads-win32.
-		#pragma warning(pop)
+		EA_RESTORE_ALL_VC_WARNINGS()
 	#endif
 
 

+ 2 - 2
source/unix/eathread_condition_unix.cpp

@@ -14,9 +14,9 @@
 	#include <errno.h>
 	#include <string.h>
 	#ifdef EA_PLATFORM_WINDOWS
-		#pragma warning(push, 0)
+		EA_DISABLE_ALL_VC_WARNINGS()
 		#include <Windows.h> // Presumably we are using pthreads-win32.
-		#pragma warning(pop)
+		EA_RESTORE_ALL_VC_WARNINGS()
 	#endif
 
 

+ 2 - 2
source/unix/eathread_mutex_unix.cpp

@@ -12,9 +12,9 @@
 	#include <errno.h>
 	#include <string.h>
 	#ifdef EA_PLATFORM_WINDOWS
-	  #pragma warning(push, 0)
+	  EA_DISABLE_ALL_VC_WARNINGS()
 	  #include <Windows.h> // Presumably we are using pthreads-win32.
-	  #pragma warning(pop)
+	  EA_RESTORE_ALL_VC_WARNINGS()
 		#ifdef CreateMutex
 			#undef CreateMutex // Windows #defines CreateMutex to CreateMutexA or CreateMutexW.
 		#endif

+ 2 - 2
source/unix/eathread_semaphore_unix.cpp

@@ -14,10 +14,10 @@
 	#include <stdio.h>
 	#include <limits.h>
 	#ifdef EA_PLATFORM_WINDOWS
-		#pragma warning(push, 0)
+		EA_DISABLE_ALL_VC_WARNINGS()
 		#include <pthread.h>
 		#include <Windows.h> // Presumably we are using pthreads-win32.
-		#pragma warning(pop)
+		EA_RESTORE_ALL_VC_WARNINGS()
 		#ifdef CreateSemaphore
 			#undef CreateSemaphore // Windows #defines CreateSemaphore to CreateSemaphoreA or CreateSemaphoreW.
 		#endif

+ 2 - 2
source/unix/eathread_unix.cpp

@@ -14,9 +14,9 @@
 	#include <sched.h>
 	#include <string.h>
 	#ifdef EA_PLATFORM_WINDOWS
-		#pragma warning(push, 0)
+		EA_DISABLE_ALL_VC_WARNINGS()
 		#include <Windows.h> // Presumably we are using pthreads-win32.
-		#pragma warning(pop)
+		EA_RESTORE_ALL_VC_WARNINGS()
 		#include <time.h>
 	#else
 		#include <unistd.h>

+ 2 - 2
source/x86/eathread_callstack_x86.cpp

@@ -24,10 +24,10 @@
 #endif
 
 #if defined(EA_COMPILER_MSVC) && defined(EA_PROCESSOR_X86_64)
-	#pragma warning(push, 0)
+	EA_DISABLE_ALL_VC_WARNINGS()
 	#include <math.h>   // VS2008 has an acknowledged bug that requires math.h (and possibly also string.h) to be #included before intrin.h.
 	#include <intrin.h>
-	#pragma warning(pop)
+	EA_RESTORE_ALL_VC_WARNINGS()
 #endif
 
 #if defined(EA_COMPILER_CLANG)

+ 2 - 1
test/thread/source/TestThreadCallstack.cpp

@@ -19,8 +19,9 @@
 
 
 #ifdef EA_PLATFORM_MICROSOFT
-#pragma warning(push, 0)
+EA_DISABLE_ALL_VC_WARNINGS()
 #include <Windows.h>
+EA_RESTORE_ALL_VC_WARNINGS()
 #endif