From ee7591b930c06449f5532f3e9c81cdfd8429636b Mon Sep 17 00:00:00 2001 From: Jakub Szuppe Date: Sat, 18 Mar 2017 15:19:57 +0100 Subject: [PATCH] Fix: snprintf is in VS only since VS2015 --- include/boost/compute/detail/parameter_cache.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/boost/compute/detail/parameter_cache.hpp b/include/boost/compute/detail/parameter_cache.hpp index 0a16cd9b..c609490c 100644 --- a/include/boost/compute/detail/parameter_cache.hpp +++ b/include/boost/compute/detail/parameter_cache.hpp @@ -24,6 +24,7 @@ #include #ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE +#include #include #include #include @@ -117,9 +118,16 @@ private: static std::string version_string() { char buf[32]; - std::snprintf(buf, sizeof(buf), "%d.%d.%d", BOOST_COMPUTE_VERSION_MAJOR, - BOOST_COMPUTE_VERSION_MINOR, - BOOST_COMPUTE_VERSION_PATCH); + // snprintf is in Visual Studio since Visual Studio 2015 (_MSC_VER == 1900) + #if defined (_MSC_VER) && _MSC_VER < 1900 + #define DETAIL_SNPRINTF sprintf_s + #else + #define DETAIL_SNPRINTF std::snprintf + #endif + DETAIL_SNPRINTF(buf, sizeof(buf), "%d.%d.%d", BOOST_COMPUTE_VERSION_MAJOR, + BOOST_COMPUTE_VERSION_MINOR, + BOOST_COMPUTE_VERSION_PATCH); + #undef DETAIL_SNPRINTF return buf; }