cereal
A C++11 library for serialization
macros.hpp
Go to the documentation of this file.
1 
17 /*
18  Copyright (c) 2014, Randolph Voorhies, Shane Grant
19  All rights reserved.
20 
21  Redistribution and use in source and binary forms, with or without
22  modification, are permitted provided that the following conditions are met:
23  * Redistributions of source code must retain the above copyright
24  notice, this list of conditions and the following disclaimer.
25  * Redistributions in binary form must reproduce the above copyright
26  notice, this list of conditions and the following disclaimer in the
27  documentation and/or other materials provided with the distribution.
28  * Neither the name of the copyright holder nor the
29  names of its contributors may be used to endorse or promote products
30  derived from this software without specific prior written permission.
31 
32  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
36  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */
43 
44 #ifndef CEREAL_MACROS_HPP_
45 #define CEREAL_MACROS_HPP_
46 
47 #ifndef CEREAL_THREAD_SAFE
48 
56 #define CEREAL_THREAD_SAFE 0
57 #endif // CEREAL_THREAD_SAFE
58 
59 #ifndef CEREAL_SIZE_TYPE
60 
70 #define CEREAL_SIZE_TYPE uint64_t
71 #endif // CEREAL_SIZE_TYPE
72 
73 // ######################################################################
74 #ifndef CEREAL_SERIALIZE_FUNCTION_NAME
75 
78 #define CEREAL_SERIALIZE_FUNCTION_NAME serialize
79 #endif // CEREAL_SERIALIZE_FUNCTION_NAME
80 
81 #ifndef CEREAL_LOAD_FUNCTION_NAME
82 
85 #define CEREAL_LOAD_FUNCTION_NAME load
86 #endif // CEREAL_LOAD_FUNCTION_NAME
87 
88 #ifndef CEREAL_SAVE_FUNCTION_NAME
89 
92 #define CEREAL_SAVE_FUNCTION_NAME save
93 #endif // CEREAL_SAVE_FUNCTION_NAME
94 
95 #ifndef CEREAL_LOAD_MINIMAL_FUNCTION_NAME
96 
99 #define CEREAL_LOAD_MINIMAL_FUNCTION_NAME load_minimal
100 #endif // CEREAL_LOAD_MINIMAL_FUNCTION_NAME
101 
102 #ifndef CEREAL_SAVE_MINIMAL_FUNCTION_NAME
103 
106 #define CEREAL_SAVE_MINIMAL_FUNCTION_NAME save_minimal
107 #endif // CEREAL_SAVE_MINIMAL_FUNCTION_NAME
108 
109 // ######################################################################
111 
114 #if !defined(CEREAL_HAS_NOEXCEPT)
115  #if defined(__clang__)
116  #if __has_feature(cxx_noexcept)
117  #define CEREAL_HAS_NOEXCEPT
118  #endif
119  #else // NOT clang
120  #if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 || \
121  defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026
122  #define CEREAL_HAS_NOEXCEPT
123  #endif // end GCC/MSVC check
124  #endif // end NOT clang block
125 
126  #ifndef CEREAL_NOEXCEPT
127  #ifdef CEREAL_HAS_NOEXCEPT
128  #define CEREAL_NOEXCEPT noexcept
129  #else
130  #define CEREAL_NOEXCEPT
131  #endif // end CEREAL_HAS_NOEXCEPT
132  #endif // end !defined(CEREAL_HAS_NOEXCEPT)
133 #endif // ifndef CEREAL_NOEXCEPT
134 
135 // ######################################################################
138 #if (__cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) \
139  && (!defined(__clang__) || __clang_major__ > 5)
140 #define CEREAL_HAS_CPP17
141 #endif
142 
144 #if __cplusplus >= 201402L
145 #define CEREAL_HAS_CPP14
146 #endif
147 
148 // ######################################################################
150 #if defined(_MSC_VER) && _MSC_VER < 1900
151 #define CEREAL_ALIGNOF __alignof
152 #else // not MSVC 2013 or older
153 #define CEREAL_ALIGNOF alignof
154 #endif // end MSVC check
155 
156 #endif // CEREAL_MACROS_HPP_