From c0c1cf113ec69573ac3286bf6622bdd4fb20a9de Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 11 Mar 2014 09:26:46 +0100 Subject: [PATCH] Logging: Proper fix. --- Escape-the-Dawn/logging.h | 10 ++++++++-- Executable/Executable.vcxproj | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Escape-the-Dawn/logging.h b/Escape-the-Dawn/logging.h index c83bdfa..cb3b140 100644 --- a/Escape-the-Dawn/logging.h +++ b/Escape-the-Dawn/logging.h @@ -2,6 +2,7 @@ #define DEBUG_H #ifdef _WIN32 +#define _CRT_SECURE_NO_WARNINGS // http://stackoverflow.com/a/2282433 #define __func__ __FUNCTION__ // http://stackoverflow.com/a/8488201 @@ -46,10 +47,13 @@ static void _LOG(_LOG_LEVEL logLevel, char* file, char* func, unsigned int line, if (logLevel > LOG_LEVEL) return; - char message[2048]; va_list args; va_start(args, format); - vsnprintf_s(message, 2048, format, args); + char* message = nullptr; + size_t size = vsnprintf(message, 0, format, args); + message = new char[size+1]; + message[size] = '\0'; + vsnprintf(message, size, format, args); va_end(args); if (logLevel == LOG_LEVEL_ERROR) @@ -61,6 +65,8 @@ static void _LOG(_LOG_LEVEL logLevel, char* file, char* func, unsigned int line, { std::cout << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; } + + delete[] message; } #define LOG(logLevel, format, ...) \ diff --git a/Executable/Executable.vcxproj b/Executable/Executable.vcxproj index 9a8c701..55c1a25 100644 --- a/Executable/Executable.vcxproj +++ b/Executable/Executable.vcxproj @@ -43,19 +43,21 @@ $(SolutionDir)bin\ $(SolutionName)-$(Configuration) $(SolutionDir)obj\$(ProjectName)\ + $(BOOST_ROOT)\lib32-msvc-11.0;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSDK_LibraryPath_x86); $(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) $(SolutionDir)bin\ $(SolutionName)-$(Configuration) $(SolutionDir)obj\$(ProjectName)\ + $(BOOST_ROOT)\lib32-msvc-11.0;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSDK_LibraryPath_x86); Level3 Disabled true - GLEW_STATIC;DEBUG;_MBCS;%(PreprocessorDefinitions) + GLEW_STATIC;_CRT_SECURE_NO_WARNINGS;DEBUG;_MBCS;%(PreprocessorDefinitions) true @@ -69,7 +71,7 @@ true true true - GLEW_STATIC;_MBCS;%(PreprocessorDefinitions) + GLEW_STATIC;_CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) true