1 /***
2  * Copyright (C) Microsoft. All rights reserved.
3  * Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4  *
5  * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
6  *
7  * Standard macros and definitions.
8  * This header has minimal dependency on windows headers and is safe for use in the public API
9  *
10  * For the latest on this and related APIs, please see: https://github.com/Microsoft/cpprestsdk
11  *
12  * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
13  ****/
14 
15 #pragma once
16 
17 #if defined(_WIN32)
18 
19 #if _MSC_VER >= 1900
20 #define CPPREST_NOEXCEPT noexcept
21 #define CPPREST_CONSTEXPR constexpr
22 #else
23 #define CPPREST_NOEXCEPT
24 #define CPPREST_CONSTEXPR const
25 #endif // _MSC_VER >= 1900
26 
27 #include <sal.h>
28 
29 #else // ^^^ _WIN32 ^^^ // vvv !_WIN32 vvv
30 
31 #define __declspec(x) __attribute__((x))
32 #define dllimport
33 #define novtable /* no novtable equivalent */
34 #define __assume(x)                                                                                                    \
35     do                                                                                                                 \
36     {                                                                                                                  \
37         if (!(x)) __builtin_unreachable();                                                                             \
38     } while (false)
39 #define CPPREST_NOEXCEPT noexcept
40 #define CPPREST_CONSTEXPR constexpr
41 
42 #include <assert.h>
43 #define _ASSERTE(x) assert(x)
44 
45 // No SAL on non Windows platforms
46 #include "cpprest/details/nosal.h"
47 
48 #if !defined(__cdecl)
49 #if defined(cdecl)
50 #define __cdecl __attribute__((cdecl))
51 #else // ^^^ defined cdecl ^^^ // vvv !defined cdecl vvv
52 #define __cdecl
53 #endif // defined cdecl
54 #endif // not defined __cdecl
55 
56 #if defined(__ANDROID__)
57 // This is needed to disable the use of __thread inside the boost library.
58 // Android does not support thread local storage -- if boost is included
59 // without this macro defined, it will create references to __tls_get_addr
60 // which (while able to link) will not be available at runtime and prevent
61 // the .so from loading.
62 #if not defined BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
63 #define BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
64 #endif // not defined BOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION
65 #endif // defined(__ANDROID__)
66 
67 #ifdef __clang__
68 #include <cstdio>
69 #endif // __clang__
70 #endif // _WIN32
71 
72 #ifdef _NO_ASYNCRTIMP
73 #define _ASYNCRTIMP
74 #else // ^^^ _NO_ASYNCRTIMP ^^^ // vvv !_NO_ASYNCRTIMP vvv
75 #ifdef _ASYNCRT_EXPORT
76 #define _ASYNCRTIMP __declspec(dllexport)
77 #else // ^^^ _ASYNCRT_EXPORT ^^^ // vvv !_ASYNCRT_EXPORT vvv
78 #define _ASYNCRTIMP __declspec(dllimport)
79 #endif // _ASYNCRT_EXPORT
80 #endif // _NO_ASYNCRTIMP
81 
82 #ifdef CASABLANCA_DEPRECATION_NO_WARNINGS
83 #define CASABLANCA_DEPRECATED(x)
84 #else
85 #define CASABLANCA_DEPRECATED(x) __declspec(deprecated(x))
86 #endif // CASABLANCA_DEPRECATION_NO_WARNINGS
87