bit7z
4.1.0
A C++ library for interfacing with the 7-zip shared libs.
Toggle main menu visibility
Loading...
Searching...
No Matches
bitdefines.hpp
1
/*
2
* bit7z - A C++ static library to interface with the 7-zip shared libraries.
3
* Copyright (c) Riccardo Ostani - All Rights Reserved.
4
*
5
* This Source Code Form is subject to the terms of the Mozilla Public
6
* License, v. 2.0. If a copy of the MPL was not distributed with this
7
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
*/
9
10
#ifndef BITDEFINES_HPP
11
#define BITDEFINES_HPP
12
13
/* Uncomment the following macros if you don't want to define them yourself in your project files,
14
* and you can't enable them via CMake. */
15
//#define BIT7Z_AUTO_FORMAT
16
//#define BIT7Z_AUTO_PREFIX_LONG_PATHS
17
//#define BIT7Z_DISABLE_USE_STD_FILESYSTEM
18
//#define BIT7Z_REGEX_MATCHING
19
//#define BIT7Z_USE_STD_BYTE
20
//#define BIT7Z_USE_NATIVE_STRING
21
22
#if defined( _MSVC_LANG ) && !defined( __clang__ )
23
# define BIT7Z_CPP_VERSION _MSVC_LANG
24
#elif defined( __cplusplus )
25
# define BIT7Z_CPP_VERSION __cplusplus
26
#else
27
# define BIT7Z_CPP_VERSION 201103L
28
#endif
29
30
#if BIT7Z_CPP_VERSION >= 202302L
31
# define BIT7Z_CPP_STANDARD 23
32
#elif BIT7Z_CPP_VERSION >= 202002L
33
# define BIT7Z_CPP_STANDARD 20
34
#elif BIT7Z_CPP_VERSION >= 201703L
35
# define BIT7Z_CPP_STANDARD 17
36
#elif BIT7Z_CPP_VERSION >= 201402L
37
# define BIT7Z_CPP_STANDARD 14
38
#else
39
# define BIT7Z_CPP_STANDARD 11
40
#endif
41
42
#ifndef BIT7Z_DISABLE_USE_STD_FILESYSTEM
43
# ifdef __cpp_lib_filesystem
44
# define BIT7Z_USE_STANDARD_FILESYSTEM
45
# elif BIT7Z_CPP_STANDARD >= 17 && defined( __has_include )
46
# if __has_include( <filesystem> )
47
# define BIT7Z_USE_STANDARD_FILESYSTEM
48
# endif
49
# endif
50
#endif
51
52
/* Macro defines for [[nodiscard]] and [[maybe_unused]] attributes. */
53
#ifdef __has_cpp_attribute
54
# if __has_cpp_attribute( nodiscard )
55
# define BIT7Z_NODISCARD [[nodiscard]]
56
# endif
57
# if __has_cpp_attribute( maybe_unused )
58
# define BIT7Z_MAYBE_UNUSED [[maybe_unused]]
59
# endif
60
# if __has_cpp_attribute( deprecated )
61
# define BIT7Z_DEPRECATED [[deprecated]]
62
# define BIT7Z_DEPRECATED_MSG( msg ) [[deprecated( msg )]]
63
# endif
64
#endif
65
66
/* The compiler doesn't support __has_cpp_attribute, but it is using the C++17 standard. */
67
#if !defined( BIT7Z_NODISCARD ) && BIT7Z_CPP_STANDARD >= 17
68
# define BIT7Z_NODISCARD [[nodiscard]]
69
#endif
70
71
#if !defined( BIT7Z_MAYBE_UNUSED ) && BIT7Z_CPP_STANDARD >= 17
72
# define BIT7Z_MAYBE_UNUSED [[maybe_unused]]
73
#endif
74
75
#if !defined( BIT7Z_DEPRECATED ) && BIT7Z_CPP_STANDARD >= 14
76
# define BIT7Z_DEPRECATED [[deprecated]]
77
# define BIT7Z_DEPRECATED_MSG( msg ) [[deprecated( msg )]]
78
#endif
79
80
/* Compiler is using at most the C++14 standard, so we use the compiler-specific attributes/defines were possible. */
81
#ifndef BIT7Z_NODISCARD
82
# if defined( __GNUC__ ) || defined(__clang__)
83
# define BIT7Z_NODISCARD __attribute__(( warn_unused_result ))
84
# elif defined( _Check_return_ )
// Old MSVC versions
85
# define BIT7Z_NODISCARD _Check_return_
86
# else
87
# define BIT7Z_NODISCARD
88
# endif
89
#endif
90
#ifndef BIT7Z_MAYBE_UNUSED
91
# if defined( __GNUC__ ) || defined(__clang__)
92
# define BIT7Z_MAYBE_UNUSED __attribute__(( unused ))
93
# else
94
# define BIT7Z_MAYBE_UNUSED
95
# endif
96
#endif
97
98
/* Compiler is using the C++11 standard, so we use the compiler-specific attributes were possible.
99
* Note: these macros are used in the public API, so we cannot assume that we are always using a C++14 compiler.*/
100
#ifndef BIT7Z_DEPRECATED
101
# if defined( __GNUC__ ) || defined( __clang__ )
102
# define BIT7Z_DEPRECATED __attribute__(( __deprecated__ ))
103
# define BIT7Z_DEPRECATED_MSG( msg ) __attribute__(( __deprecated__( msg ) ))
104
# elif defined( _MSC_VER )
105
# define BIT7Z_DEPRECATED __declspec( deprecated )
106
# define BIT7Z_DEPRECATED_MSG( msg ) __declspec( deprecated( msg ) )
107
# else
108
# define BIT7Z_DEPRECATED
109
# define BIT7Z_DEPRECATED_MSG( msg )
110
# endif
111
#endif
112
113
#ifndef BIT7Z_DEPRECATED_ENUMERATOR
114
// Before v6.0, GCC didn't support deprecating single enumerators.
115
# if defined( __GNUC__ ) && !defined( __clang__ ) && __GNUC__ < 6
116
# define BIT7Z_DEPRECATED_ENUMERATOR( deprecated_value, new_value, msg ) deprecated_value = new_value
117
# else
118
# define BIT7Z_DEPRECATED_ENUMERATOR( deprecated_value, new_value, msg ) \
119
deprecated_value BIT7Z_DEPRECATED_MSG( msg ) = new_value
120
# endif
121
#endif
122
123
#ifndef BIT7Z_DEPRECATED_TYPEDEF
124
# if defined( __GNUC__ ) && !defined( __clang__ ) && __GNUC__ < 7
125
# define BIT7Z_DEPRECATED_TYPEDEF( alias_name, alias_value, msg ) \
126
using alias_name BIT7Z_MAYBE_UNUSED __attribute__(( __deprecated__( msg ) )) = alias_value
127
# else
128
# define BIT7Z_DEPRECATED_TYPEDEF( alias_name, alias_value, msg ) \
129
using alias_name BIT7Z_MAYBE_UNUSED BIT7Z_DEPRECATED_MSG( msg ) = alias_value
130
# endif
131
#endif
132
133
#ifdef __GNUC__
134
# define BIT7Z_ALWAYS_INLINE [[gnu::always_inline]] inline
135
#elif defined( _WIN32 )
136
# define BIT7Z_ALWAYS_INLINE __forceinline
137
#else
138
# define BIT7Z_ALWAYS_INLINE inline
139
#endif
140
141
// Note: MSVC 2015 doesn't fully support C++14's constexpr
142
#if BIT7Z_CPP_STANDARD >= 14 && !( defined( _MSC_VER ) && _MSC_VER <= 1900 )
143
# define BIT7Z_CPP14_CONSTEXPR constexpr
144
#else
145
# define BIT7Z_CPP14_CONSTEXPR
/*constexpr*/
146
#endif
147
148
#endif
//BITDEFINES_HPP
include
bit7z
bitdefines.hpp
Generated by
1.17.0