Skip to content

Fix VS 2013 builds. #932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions Release/include/cpprest/details/cpprest_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,21 @@

#pragma once

#if defined(_WIN32) // Settings specific to Windows
#if defined(_WIN32)

#if _MSC_VER >= 1900
#define CPPREST_NOEXCEPT noexcept
#define CPPREST_CONSTEXPR constexpr
#else
#define CPPREST_NOEXCEPT
#define CPPREST_CONSTEXPR const
#endif
#endif // _MSC_VER >= 1900

#define CASABLANCA_UNREFERENCED_PARAMETER(x) (x)

#include <sal.h>

#else // End settings specific to Windows

// Settings common to all but Windows
#else // ^^^ _WIN32 ^^^ // vvv !_WIN32 vvv

#define __declspec(x) __attribute__ ((x))
#define dllimport
Expand All @@ -49,9 +47,10 @@
#if not defined __cdecl
#if defined cdecl
#define __cdecl __attribute__ ((cdecl))
#else
#else // ^^^ defined cdecl ^^^ // vvv !defined cdecl vvv
#define __cdecl
#endif
#endif // defined cdecl
#endif // not defined __cdecl

#if defined(__ANDROID__)
// This is needed to disable the use of __thread inside the boost library.
Expand All @@ -61,30 +60,27 @@
// the .so from loading.
#if not defined BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
#define BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
#endif
#endif
#endif // not defined BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
#endif // defined(__ANDROID__)

#ifdef __clang__
#include <cstdio>
#endif

#endif // defined(__APPLE__)

#endif
#endif // __clang__
#endif // _WIN32


#ifdef _NO_ASYNCRTIMP
#define _ASYNCRTIMP
#else
#else // ^^^ _NO_ASYNCRTIMP ^^^ // vvv !_NO_ASYNCRTIMP vvv
#ifdef _ASYNCRT_EXPORT
#define _ASYNCRTIMP __declspec(dllexport)
#else
#else // ^^^ _ASYNCRT_EXPORT ^^^ // vvv !_ASYNCRT_EXPORT vvv
#define _ASYNCRTIMP __declspec(dllimport)
#endif
#endif
#endif // _ASYNCRT_EXPORT
#endif // _NO_ASYNCRTIMP

#ifdef CASABLANCA_DEPRECATION_NO_WARNINGS
#define CASABLANCA_DEPRECATED(x)
#else
#define CASABLANCA_DEPRECATED(x) __declspec(deprecated(x))
#endif
#endif // CASABLANCA_DEPRECATION_NO_WARNINGS
12 changes: 9 additions & 3 deletions Release/include/cpprest/http_compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,15 @@ _ASYNCRTIMP bool supported();
/// </summary>
namespace algorithm
{
constexpr const utility::char_t *GZIP = _XPLATSTR("gzip");
constexpr const utility::char_t *DEFLATE = _XPLATSTR("deflate");
constexpr const utility::char_t *BROTLI = _XPLATSTR("br");
#if defined(_MSC_VER) && _MSC_VER < 1900
const utility::char_t * const GZIP = _XPLATSTR("gzip");
const utility::char_t * const DEFLATE = _XPLATSTR("deflate");
const utility::char_t * const BROTLI = _XPLATSTR("br");
#else // ^^^ VS2013 and before ^^^ // vvv VS2015+, and everything else vvv
constexpr const utility::char_t * const GZIP = _XPLATSTR("gzip");
constexpr const utility::char_t * const DEFLATE = _XPLATSTR("deflate");
constexpr const utility::char_t * const BROTLI = _XPLATSTR("br");
#endif

/// <summary>
/// Test whether cpprestsdk was built with built-in compression support and
Expand Down
30 changes: 30 additions & 0 deletions Release/src/http/client/http_client_winhttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,36 @@ class winhttp_request_context final : public request_context
{
}

#if defined(_MSC_VER) && _MSC_VER < 1900
compression_state(const compression_state&) = delete;
compression_state(compression_state&& other)
: m_buffer(std::move(other.m_buffer))
, m_acquired(other.m_acquired)
, m_bytes_read(other.m_bytes_read)
, m_bytes_processed(other.m_bytes_processed)
, m_needs_flush(other.m_needs_flush)
, m_started(other.m_started)
, m_done(other.m_done)
, m_chunked(other.m_chunked)
, m_chunk_bytes(other.m_chunk_bytes)
, m_chunk(std::move(other.m_chunk))
{}
compression_state& operator=(const compression_state&) = delete;
compression_state& operator=(compression_state&& other) {
m_buffer = std::move(other.m_buffer);
m_acquired = other.m_acquired;
m_bytes_read = other.m_bytes_read;
m_bytes_processed = other.m_bytes_processed;
m_needs_flush = other.m_needs_flush;
m_started = other.m_started;
m_done = other.m_done;
m_chunked = other.m_chunked;
m_chunk_bytes = other.m_chunk_bytes;
m_chunk = std::move(other.m_chunk);
return *this;
}
#endif // defined(_MSC_VER) && _MSC_VER < 1900

// Minimal state for on-the-fly decoding of "chunked" encoded data
class _chunk_helper
{
Expand Down
4 changes: 2 additions & 2 deletions Release/src/json/json_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ std::unique_ptr<web::json::details::_Value> JSON_Parser<CharType>::_ParseObject(
::std::sort(elems.begin(), elems.end(), json::object::compare_pairs);
}

return obj;
return std::unique_ptr<web::json::details::_Value>(obj.release());

error:
if (!tkn.m_error)
Expand Down Expand Up @@ -1076,7 +1076,7 @@ std::unique_ptr<web::json::details::_Value> JSON_Parser<CharType>::_ParseArray(t
GetNextToken(tkn);
if (tkn.m_error) return utility::details::make_unique<web::json::details::_Null>();

return std::move(result);
return std::unique_ptr<web::json::details::_Value>(result.release());
}

template <typename CharType>
Expand Down
4 changes: 2 additions & 2 deletions Release/src/pplx/threadpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct threadpool_impl final : crossplat::threadpool
#if defined(_WIN32)
struct shared_threadpool
{
typename std::aligned_union<0, threadpool_impl>::type shared_storage;
std::aligned_union<0, threadpool_impl>::type shared_storage;

threadpool_impl& get_shared()
{
Expand Down Expand Up @@ -140,7 +140,7 @@ typedef threadpool_impl platform_shared_threadpool;

std::pair<bool, platform_shared_threadpool*> initialize_shared_threadpool(size_t num_threads)
{
static typename std::aligned_union<0, platform_shared_threadpool>::type storage;
static std::aligned_union<0, platform_shared_threadpool>::type storage;
platform_shared_threadpool* const ptr =
&reinterpret_cast<platform_shared_threadpool&>(storage);
bool initialized_this_time = false;
Expand Down
4 changes: 2 additions & 2 deletions Release/tests/common/UnitTestpp/src/CurrentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

namespace {
std::atomic<UnitTest::TestResults *> testResults;
std::atomic<const UnitTest::TestDetails *> testDetails;
std::atomic<UnitTest::TestDetails *> testDetails; // non-const pointer to avoid VS2013 STL bug
}

namespace UnitTest {
Expand All @@ -54,7 +54,7 @@ UNITTEST_LINKAGE const TestDetails* CurrentTest::Details()
}

UNITTEST_LINKAGE void CurrentTest::SetDetails(const UnitTest::TestDetails * d) {
testDetails.store(d);
testDetails.store(const_cast<UnitTest::TestDetails *>(d));
}

}