Added compiler-specific CDS_DEPRECATED macro
[libcds.git] / cds / compiler / vc / defs.h
1 //$$CDS-header$$
2
3 #ifndef CDSLIB_COMPILER_VC_DEFS_H
4 #define CDSLIB_COMPILER_VC_DEFS_H
5 //@cond
6
7 // Compiler version
8 #define CDS_COMPILER_VERSION    _MSC_VER
9
10 // Compiler name
11 // Supported compilers: MS VC 2013
12 // C++ compiler versions:
13 #define CDS_COMPILER_MSVC12 1800    // 2013 vc12
14 #define CDS_COMPILER_MSVC14 1900    // 2015 vc14
15
16 #if CDS_COMPILER_VERSION < CDS_COMPILER_MSVC12
17 #   error "Only MS Visual C++ 12 (2013) Update 4 and above is supported"
18 #endif
19
20 #if _MSC_VER == 1800
21 #   define  CDS_COMPILER__NAME  "MS Visual C++ 2013"
22 #   define  CDS_COMPILER__NICK  "vc12"
23 #elif _MSC_VER == 1900
24 #   define  CDS_COMPILER__NAME  "MS Visual C++ 2015"
25 #   define  CDS_COMPILER__NICK  "vc14"
26 #else
27 #   define  CDS_COMPILER__NAME  "MS Visual C++"
28 #   define  CDS_COMPILER__NICK  "msvc"
29 #endif
30
31 // OS interface
32 #define CDS_OS_INTERFACE CDS_OSI_WINDOWS
33
34 // OS name
35 #if defined(_WIN64)
36 #   define CDS_OS_TYPE      CDS_OS_WIN64
37 #   define CDS_OS__NAME     "Win64"
38 #   define CDS_OS__NICK     "Win64"
39 #elif defined(_WIN32)
40 #   define CDS_OS_TYPE      CDS_OS_WIN32
41 #   define CDS_OS__NAME     "Win32"
42 #   define CDS_OS__NICK     "Win32"
43 #endif
44
45 // Processor architecture
46 #ifdef _M_IX86
47 #   define CDS_BUILD_BITS       32
48 #   define CDS_PROCESSOR_ARCH   CDS_PROCESSOR_X86
49 #   define CDS_PROCESSOR__NAME  "Intel x86"
50 #   define CDS_PROCESSOR__NICK  "x86"
51 #elif _M_X64
52 #   define CDS_BUILD_BITS       64
53 #   define CDS_PROCESSOR_ARCH   CDS_PROCESSOR_AMD64
54 #   define CDS_PROCESSOR__NAME  "AMD64"
55 #   define CDS_PROCESSOR__NICK  "amd64"
56 #else
57 #   define CDS_BUILD_BITS        -1
58 #   define CDS_PROCESSOR_ARCH    CDS_PROCESSOR_UNKNOWN
59 #   define CDS_PROCESSOR__NAME    "<<Undefined>>"
60 #   error Microsoft Visual C++ compiler is supported for x86 only
61 #endif
62
63 #define  __attribute__( _x )
64
65 #define  CDS_STDCALL    __stdcall
66
67 #ifdef CDS_BUILD_LIB
68 #   define CDS_EXPORT_API          __declspec(dllexport)
69 #else
70 #   define CDS_EXPORT_API          __declspec(dllimport)
71 #endif
72
73 #define alignof     __alignof
74
75 // Memory leaks detection (debug build only)
76 #ifdef _DEBUG
77 #   define _CRTDBG_MAP_ALLOC
78 #   define _CRTDBG_MAPALLOC
79 #   include <stdlib.h>
80 #   include <crtdbg.h>
81 #   define CDS_MSVC_MEMORY_LEAKS_DETECTING_ENABLED
82 #endif
83
84 // constexpr is not yet supported
85 #define CDS_CONSTEXPR
86
87 // noexcept - vc14 +
88 #if CDS_COMPILER_VERSION > CDS_COMPILER_MSVC12
89 #   define CDS_NOEXCEPT_SUPPORT        noexcept
90 #   define CDS_NOEXCEPT_SUPPORT_(expr) noexcept(expr)
91 #else
92 #   define CDS_NOEXCEPT_SUPPORT
93 #   define CDS_NOEXCEPT_SUPPORT_(expr)
94 #endif
95
96 // C++11 inline namespace
97 #if CDS_COMPILER_VERSION > CDS_COMPILER_MSVC12
98 #   define CDS_CXX11_INLINE_NAMESPACE_SUPPORT
99 #endif
100
101 #if CDS_COMPILER_VERSION == CDS_COMPILER_MSVC12
102     // VC12: move ctor cannot be defaulted
103     // Error: C2610 [move ctor] is not a special member function which can be defaulted
104 #   define CDS_DISABLE_DEFAULT_MOVE_CTOR
105 #endif
106
107 // Full SFINAE support
108 #if CDS_COMPILER_VERSION > CDS_COMPILER_MSVC12
109 #   define CDS_CXX11_SFINAE
110 #endif
111
112 // Inheriting constructors
113 #if CDS_COMPILER_VERSION > CDS_COMPILER_MSVC12
114 #   define CDS_CXX11_INHERITING_CTOR
115 #endif
116
117 // *************************************************
118 // Alignment macro
119
120 #define CDS_TYPE_ALIGNMENT(n)     __declspec( align(n) )
121 #define CDS_DATA_ALIGNMENT(n)     __declspec( align(n) )
122 #define CDS_CLASS_ALIGNMENT(n)    __declspec( align(n) )
123
124 // Attributes
125 #define CDS_DEPRECATED( reason ) __declspec(deprecated( reason ))
126
127 #include <cds/compiler/vc/compiler_barriers.h>
128
129 //@endcond
130 #endif // #ifndef CDSLIB_COMPILER_VC_DEFS_H