From 8e3bd6781e1416b1d8f1a15b39eab767849d5f58 Mon Sep 17 00:00:00 2001 From: "fires.gc" Date: Wed, 15 Oct 2008 12:40:31 +0000 Subject: [PATCH] added compile time assertion for _SECURE_SCL=0. It is very important that all libraries are compiled with the same _SECURE_SCL if you want to share STL functions between libraries. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@876 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/Common.h | 20 ++ Source/Core/Core/Core.vcproj | 322 +++++++++--------- Source/Core/DebuggerWX/DebuggerWX.vcproj | 4 +- Source/Core/DiscIO/DiscIO.vcproj | 8 +- Source/Core/DolphinWX/DolphinWX.vcproj | 4 +- Source/Core/VideoCommon/VideoCommon.vcproj | 8 +- .../Plugin_DSP_HLE/Plugin_DSP_HLE.vcproj | 12 +- .../Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj | 12 +- .../Plugin_DSP_NULL/Plugin_DSP_NULL.vcproj | 14 +- .../Plugin_PadSimple/Plugin_PadSimple.vcproj | 29 +- .../Plugin_Wiimote_Test.vcproj | 12 +- .../Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj | 12 +- 12 files changed, 230 insertions(+), 227 deletions(-) diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h index 234334d3c6..2fcb2e5613 100644 --- a/Source/Core/Common/Src/Common.h +++ b/Source/Core/Common/Src/Common.h @@ -254,4 +254,24 @@ void Host_UpdateLogDisplay(); #define _assert_(a) #define _assert_msg_(...) #endif + +// compile time asserts +namespace +{ + +// it is very risky to mix _SECURE_SCL=0 and _SECURE_SCL=1 compiled libraries +// it is possible that you overwrite memory if you do it + +#ifndef _SECURE_SCL + #error Please define _SECURE_SCL=0 in the project settings +#else + template struct CompileTimeAssert; + template<> struct CompileTimeAssert {}; + CompileTimeAssert<_SECURE_SCL==0> x; #endif + +} + +#endif // #ifndef _COMMON_H + + diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index 1d9bc5f678..20fb7b864b 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -89,6 +89,77 @@ Name="VCPostBuildEventTool" /> + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - @@ -1307,6 +1291,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1315,6 +1307,14 @@ UsePrecompiledHeader="1" /> + + + diff --git a/Source/Core/DebuggerWX/DebuggerWX.vcproj b/Source/Core/DebuggerWX/DebuggerWX.vcproj index 20ec418e6c..7d929dc577 100644 --- a/Source/Core/DebuggerWX/DebuggerWX.vcproj +++ b/Source/Core/DebuggerWX/DebuggerWX.vcproj @@ -47,7 +47,7 @@ Optimization="0" WholeProgramOptimization="false" AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;..\Common\Src;..\..\..\Externals\Bochs_disasm" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__WXMSW__" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__WXMSW__;_SECURE_SCL=0" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -114,7 +114,7 @@ Optimization="0" WholeProgramOptimization="false" AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;..\Common\Src;..\..\..\Externals\Bochs_disasm" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__WXMSW__" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__WXMSW__;_SECURE_SCL=0" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" diff --git a/Source/Core/DiscIO/DiscIO.vcproj b/Source/Core/DiscIO/DiscIO.vcproj index 6dafef66d4..9306ed97e3 100644 --- a/Source/Core/DiscIO/DiscIO.vcproj +++ b/Source/Core/DiscIO/DiscIO.vcproj @@ -46,7 +46,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\Common\Src" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_SECURE_SCL=0" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -112,7 +112,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\Common\Src" - PreprocessorDefinitions="WIN32;_DEBUG;_LIB" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_SECURE_SCL=0" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -303,7 +303,7 @@ @@ -674,7 +671,6 @@ @@ -684,7 +680,6 @@ @@ -711,7 +705,6 @@ @@ -739,7 +730,6 @@ @@ -757,7 +747,6 @@ @@ -778,7 +767,6 @@ @@ -788,7 +776,6 @@ @@ -798,7 +785,6 @@ @@ -809,7 +795,6 @@ @@ -820,7 +805,6 @@ @@ -830,7 +814,6 @@ diff --git a/Source/Plugins/Plugin_Wiimote_Test/Plugin_Wiimote_Test.vcproj b/Source/Plugins/Plugin_Wiimote_Test/Plugin_Wiimote_Test.vcproj index ece19870c2..d806b8c20b 100644 --- a/Source/Plugins/Plugin_Wiimote_Test/Plugin_Wiimote_Test.vcproj +++ b/Source/Plugins/Plugin_Wiimote_Test/Plugin_Wiimote_Test.vcproj @@ -45,7 +45,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\include;..\..\Core\Common\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" - PreprocessorDefinitions="LOGGING;WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_WIIMOTE_TEST_EXPORTS" + PreprocessorDefinitions="LOGGING;WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_WIIMOTE_TEST_EXPORTS;_SECURE_SCL=0" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -128,7 +128,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\SDL\include;..\..\Core\Common\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_WIIMOTE_TEST_EXPORTS" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PLUGIN_WIIMOTE_TEST_EXPORTS;_SECURE_SCL=0" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -210,7 +210,7 @@