No longer support VS 2013 and older #1325 (#1326)

* Fixed a warning

* No longer support VS 2013 and older (Fix #1325)
This commit is contained in:
yhirose 2022-07-14 20:57:41 -04:00 committed by GitHub
parent 5e6f973b99
commit 37bb3c6a77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 20 deletions

View file

@ -123,15 +123,17 @@
#endif //_CRT_NONSTDC_NO_DEPRECATE
#if defined(_MSC_VER)
#if _MSC_VER < 1900
#error Sorry, Visual Studio versions prior to 2015 are not supported
#endif
#pragma comment(lib, "ws2_32.lib")
#ifdef _WIN64
using ssize_t = __int64;
#else
using ssize_t = int;
#endif
#if _MSC_VER < 1900
#define snprintf _snprintf_s
#endif
#endif // _MSC_VER
#ifndef S_ISREG
@ -154,10 +156,6 @@ using ssize_t = int;
#define WSA_FLAG_NO_HANDLE_INHERIT 0x80
#endif
#ifdef _MSC_VER
#pragma comment(lib, "ws2_32.lib")
#endif
#ifndef strcasecmp
#define strcasecmp _stricmp
#endif // strcasecmp
@ -1520,11 +1518,7 @@ inline ssize_t Stream::write_format(const char *fmt, const Args &...args) {
const auto bufsiz = 2048;
std::array<char, bufsiz> buf{};
#if defined(_MSC_VER) && _MSC_VER < 1900
auto sn = _snprintf_s(buf.data(), bufsiz, _TRUNCATE, fmt, args...);
#else
auto sn = snprintf(buf.data(), buf.size() - 1, fmt, args...);
#endif
if (sn <= 0) { return sn; }
auto n = static_cast<size_t>(sn);
@ -1534,14 +1528,8 @@ inline ssize_t Stream::write_format(const char *fmt, const Args &...args) {
while (n >= glowable_buf.size() - 1) {
glowable_buf.resize(glowable_buf.size() * 2);
#if defined(_MSC_VER) && _MSC_VER < 1900
n = static_cast<size_t>(_snprintf_s(&glowable_buf[0], glowable_buf.size(),
glowable_buf.size() - 1, fmt,
args...));
#else
n = static_cast<size_t>(
snprintf(&glowable_buf[0], glowable_buf.size() - 1, fmt, args...));
#endif
}
return write(&glowable_buf[0], n);
} else {
@ -4711,7 +4699,7 @@ inline bool BufferStream::is_readable() const { return true; }
inline bool BufferStream::is_writable() const { return true; }
inline ssize_t BufferStream::read(char *ptr, size_t size) {
#if defined(_MSC_VER) && _MSC_VER <= 1900
#if defined(_MSC_VER) && _MSC_VER < 1910
auto len_read = buffer._Copy_s(ptr, size, size, position);
#else
auto len_read = buffer.copy(ptr, size, position);

View file

@ -4982,7 +4982,7 @@ TEST(MultipartFormDataTest, LargeData) {
TEST(MultipartFormDataTest, WithPreamble) {
Server svr;
svr.Post("/post", [&](const Request &req, Response &res) {
svr.Post("/post", [&](const Request & /*req*/, Response &res) {
res.set_content("ok", "text/plain");
});