2
0
mirror of https://github.com/boostorg/compute.git synced 2026-02-24 03:52:14 +00:00

Fix: snprintf is in VS only since VS2015

This commit is contained in:
Jakub Szuppe
2017-03-18 15:19:57 +01:00
parent cc30762666
commit ee7591b930

View File

@@ -24,6 +24,7 @@
#include <boost/compute/version.hpp>
#ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE
#include <cstdio>
#include <boost/algorithm/string/trim.hpp>
#include <boost/compute/detail/path.hpp>
#include <boost/property_tree/ptree.hpp>
@@ -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;
}