Skip to content

Commit f4c08f0

Browse files
authored
Fix VS 2013 builds. (#932)
* Fix VS 2013 builds. * Fixed up bad #endif and constexpr.
1 parent 4c554bf commit f4c08f0

File tree

6 files changed

+60
-28
lines changed

6 files changed

+60
-28
lines changed

Release/include/cpprest/details/cpprest_compat.h

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,21 @@
1414

1515
#pragma once
1616

17-
#if defined(_WIN32) // Settings specific to Windows
17+
#if defined(_WIN32)
1818

1919
#if _MSC_VER >= 1900
2020
#define CPPREST_NOEXCEPT noexcept
2121
#define CPPREST_CONSTEXPR constexpr
2222
#else
2323
#define CPPREST_NOEXCEPT
2424
#define CPPREST_CONSTEXPR const
25-
#endif
25+
#endif // _MSC_VER >= 1900
2626

2727
#define CASABLANCA_UNREFERENCED_PARAMETER(x) (x)
2828

2929
#include <sal.h>
3030

31-
#else // End settings specific to Windows
32-
33-
// Settings common to all but Windows
31+
#else // ^^^ _WIN32 ^^^ // vvv !_WIN32 vvv
3432

3533
#define __declspec(x) __attribute__ ((x))
3634
#define dllimport
@@ -49,9 +47,10 @@
4947
#if not defined __cdecl
5048
#if defined cdecl
5149
#define __cdecl __attribute__ ((cdecl))
52-
#else
50+
#else // ^^^ defined cdecl ^^^ // vvv !defined cdecl vvv
5351
#define __cdecl
54-
#endif
52+
#endif // defined cdecl
53+
#endif // not defined __cdecl
5554

5655
#if defined(__ANDROID__)
5756
// This is needed to disable the use of __thread inside the boost library.
@@ -61,30 +60,27 @@
6160
// the .so from loading.
6261
#if not defined BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
6362
#define BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
64-
#endif
65-
#endif
63+
#endif // not defined BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
64+
#endif // defined(__ANDROID__)
6665

6766
#ifdef __clang__
6867
#include <cstdio>
69-
#endif
70-
71-
#endif // defined(__APPLE__)
72-
73-
#endif
68+
#endif // __clang__
69+
#endif // _WIN32
7470

7571

7672
#ifdef _NO_ASYNCRTIMP
7773
#define _ASYNCRTIMP
78-
#else
74+
#else // ^^^ _NO_ASYNCRTIMP ^^^ // vvv !_NO_ASYNCRTIMP vvv
7975
#ifdef _ASYNCRT_EXPORT
8076
#define _ASYNCRTIMP __declspec(dllexport)
81-
#else
77+
#else // ^^^ _ASYNCRT_EXPORT ^^^ // vvv !_ASYNCRT_EXPORT vvv
8278
#define _ASYNCRTIMP __declspec(dllimport)
83-
#endif
84-
#endif
79+
#endif // _ASYNCRT_EXPORT
80+
#endif // _NO_ASYNCRTIMP
8581

8682
#ifdef CASABLANCA_DEPRECATION_NO_WARNINGS
8783
#define CASABLANCA_DEPRECATED(x)
8884
#else
8985
#define CASABLANCA_DEPRECATED(x) __declspec(deprecated(x))
90-
#endif
86+
#endif // CASABLANCA_DEPRECATION_NO_WARNINGS

Release/include/cpprest/http_compression.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,15 @@ _ASYNCRTIMP bool supported();
117117
/// </summary>
118118
namespace algorithm
119119
{
120-
constexpr const utility::char_t *GZIP = _XPLATSTR("gzip");
121-
constexpr const utility::char_t *DEFLATE = _XPLATSTR("deflate");
122-
constexpr const utility::char_t *BROTLI = _XPLATSTR("br");
120+
#if defined(_MSC_VER) && _MSC_VER < 1900
121+
const utility::char_t * const GZIP = _XPLATSTR("gzip");
122+
const utility::char_t * const DEFLATE = _XPLATSTR("deflate");
123+
const utility::char_t * const BROTLI = _XPLATSTR("br");
124+
#else // ^^^ VS2013 and before ^^^ // vvv VS2015+, and everything else vvv
125+
constexpr const utility::char_t * const GZIP = _XPLATSTR("gzip");
126+
constexpr const utility::char_t * const DEFLATE = _XPLATSTR("deflate");
127+
constexpr const utility::char_t * const BROTLI = _XPLATSTR("br");
128+
#endif
123129

124130
/// <summary>
125131
/// Test whether cpprestsdk was built with built-in compression support and

Release/src/http/client/http_client_winhttp.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,36 @@ class winhttp_request_context final : public request_context
302302
{
303303
}
304304

305+
#if defined(_MSC_VER) && _MSC_VER < 1900
306+
compression_state(const compression_state&) = delete;
307+
compression_state(compression_state&& other)
308+
: m_buffer(std::move(other.m_buffer))
309+
, m_acquired(other.m_acquired)
310+
, m_bytes_read(other.m_bytes_read)
311+
, m_bytes_processed(other.m_bytes_processed)
312+
, m_needs_flush(other.m_needs_flush)
313+
, m_started(other.m_started)
314+
, m_done(other.m_done)
315+
, m_chunked(other.m_chunked)
316+
, m_chunk_bytes(other.m_chunk_bytes)
317+
, m_chunk(std::move(other.m_chunk))
318+
{}
319+
compression_state& operator=(const compression_state&) = delete;
320+
compression_state& operator=(compression_state&& other) {
321+
m_buffer = std::move(other.m_buffer);
322+
m_acquired = other.m_acquired;
323+
m_bytes_read = other.m_bytes_read;
324+
m_bytes_processed = other.m_bytes_processed;
325+
m_needs_flush = other.m_needs_flush;
326+
m_started = other.m_started;
327+
m_done = other.m_done;
328+
m_chunked = other.m_chunked;
329+
m_chunk_bytes = other.m_chunk_bytes;
330+
m_chunk = std::move(other.m_chunk);
331+
return *this;
332+
}
333+
#endif // defined(_MSC_VER) && _MSC_VER < 1900
334+
305335
// Minimal state for on-the-fly decoding of "chunked" encoded data
306336
class _chunk_helper
307337
{

Release/src/json/json_parsing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ std::unique_ptr<web::json::details::_Value> JSON_Parser<CharType>::_ParseObject(
10291029
::std::sort(elems.begin(), elems.end(), json::object::compare_pairs);
10301030
}
10311031

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

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

1079-
return std::move(result);
1079+
return std::unique_ptr<web::json::details::_Value>(result.release());
10801080
}
10811081

10821082
template <typename CharType>

Release/src/pplx/threadpool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct threadpool_impl final : crossplat::threadpool
110110
#if defined(_WIN32)
111111
struct shared_threadpool
112112
{
113-
typename std::aligned_union<0, threadpool_impl>::type shared_storage;
113+
std::aligned_union<0, threadpool_impl>::type shared_storage;
114114

115115
threadpool_impl& get_shared()
116116
{
@@ -140,7 +140,7 @@ typedef threadpool_impl platform_shared_threadpool;
140140

141141
std::pair<bool, platform_shared_threadpool*> initialize_shared_threadpool(size_t num_threads)
142142
{
143-
static typename std::aligned_union<0, platform_shared_threadpool>::type storage;
143+
static std::aligned_union<0, platform_shared_threadpool>::type storage;
144144
platform_shared_threadpool* const ptr =
145145
&reinterpret_cast<platform_shared_threadpool&>(storage);
146146
bool initialized_this_time = false;

Release/tests/common/UnitTestpp/src/CurrentTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

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

4040
namespace UnitTest {
@@ -54,7 +54,7 @@ UNITTEST_LINKAGE const TestDetails* CurrentTest::Details()
5454
}
5555

5656
UNITTEST_LINKAGE void CurrentTest::SetDetails(const UnitTest::TestDetails * d) {
57-
testDetails.store(d);
57+
testDetails.store(const_cast<UnitTest::TestDetails *>(d));
5858
}
5959

6060
}

0 commit comments

Comments
 (0)