bit7z
4.0.9
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bitdefines.hpp
1
/*
2
* bit7z - A C++ static library to interface with the 7-zip shared libraries.
3
* Copyright (c) 2014-2023 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 ) && _MSVC_LANG >= 201703L ) || ( defined( __cplusplus ) && __cplusplus >= 201703L )
23
# define BIT7Z_CPP_STANDARD 17
24
#elif ( defined( _MSVC_LANG ) && _MSVC_LANG >= 201402L ) || ( defined( __cplusplus ) && __cplusplus >= 201402L )
25
# define BIT7Z_CPP_STANDARD 14
26
#else
27
# define BIT7Z_CPP_STANDARD 11
28
#endif
29
30
#ifndef BIT7Z_DISABLE_USE_STD_FILESYSTEM
31
# if defined( __cpp_lib_filesystem )
32
# define BIT7Z_USE_STANDARD_FILESYSTEM
33
# elif BIT7Z_CPP_STANDARD >= 17 && defined( __has_include )
34
# if __has_include( <filesystem> )
35
# define BIT7Z_USE_STANDARD_FILESYSTEM
36
# endif
37
# endif
38
#endif
39
40
/* Macro defines for [[nodiscard]] and [[maybe_unused]] attributes. */
41
#if defined( __has_cpp_attribute )
42
# if __has_cpp_attribute( nodiscard )
43
# define BIT7Z_NODISCARD [[nodiscard]]
44
# endif
45
# if __has_cpp_attribute( maybe_unused )
46
# define BIT7Z_MAYBE_UNUSED [[maybe_unused]]
47
# endif
48
# if __has_cpp_attribute( deprecated )
49
# define BIT7Z_DEPRECATED [[deprecated]]
50
# define BIT7Z_DEPRECATED_MSG( msg ) [[deprecated( msg )]]
51
# endif
52
#endif
53
54
/* The compiler doesn't support __has_cpp_attribute, but it is using the C++17 standard. */
55
#if !defined( BIT7Z_NODISCARD ) && BIT7Z_CPP_STANDARD >= 17
56
# define BIT7Z_NODISCARD [[nodiscard]]
57
#endif
58
59
#if !defined( BIT7Z_MAYBE_UNUSED ) && BIT7Z_CPP_STANDARD >= 17
60
# define BIT7Z_MAYBE_UNUSED [[maybe_unused]]
61
#endif
62
63
#if !defined( BIT7Z_DEPRECATED ) && BIT7Z_CPP_STANDARD >= 14
64
# define BIT7Z_DEPRECATED [[deprecated]]
65
# define BIT7Z_DEPRECATED_MSG( msg ) [[deprecated( msg )]]
66
#endif
67
68
/* Compiler is using at most the C++14 standard, so we use the compiler-specific attributes/defines were possible. */
69
#ifndef BIT7Z_NODISCARD
70
# if defined( __GNUC__ ) || defined(__clang__)
71
# define BIT7Z_NODISCARD __attribute__(( warn_unused_result ))
72
# elif defined( _Check_return_ )
// Old MSVC versions
73
# define BIT7Z_NODISCARD _Check_return_
74
# else
75
# define BIT7Z_NODISCARD
76
# endif
77
#endif
78
#ifndef BIT7Z_MAYBE_UNUSED
79
# if defined( __GNUC__ ) || defined(__clang__)
80
# define BIT7Z_MAYBE_UNUSED __attribute__(( unused ))
81
# else
82
# define BIT7Z_MAYBE_UNUSED
83
# endif
84
#endif
85
86
/* Compiler is using the C++11 standard, so we use the compiler-specific attributes were possible.
87
* Note: these macros are used in the public API, so we cannot assume that we are always using a C++14 compiler.*/
88
#ifndef BIT7Z_DEPRECATED
89
# if defined( __GNUC__ ) || defined( __clang__ )
90
# define BIT7Z_DEPRECATED __attribute__(( __deprecated__ ))
91
# define BIT7Z_DEPRECATED_MSG( msg ) __attribute__(( __deprecated__( msg ) ))
92
# elif defined( _MSC_VER )
93
# define BIT7Z_DEPRECATED __declspec( deprecated )
94
# define BIT7Z_DEPRECATED_MSG( msg ) __declspec( deprecated( msg ) )
95
# else
96
# define BIT7Z_DEPRECATED
97
# define BIT7Z_DEPRECATED_MSG( msg )
98
# endif
99
#endif
100
101
#ifndef BIT7Z_DEPRECATED_ENUMERATOR
102
// Before v6.0, GCC didn't support deprecating single enumerators.
103
# if defined( __GNUC__ ) && !defined( __clang__ ) && __GNUC__ < 6
104
# define BIT7Z_DEPRECATED_ENUMERATOR( deprecated_value, new_value, msg ) deprecated_value = new_value
105
# else
106
# define BIT7Z_DEPRECATED_ENUMERATOR( deprecated_value, new_value, msg ) \
107
deprecated_value BIT7Z_DEPRECATED_MSG( msg ) = new_value
108
# endif
109
#endif
110
111
#ifndef BIT7Z_DEPRECATED_TYPEDEF
112
# if defined( __GNUC__ ) && !defined( __clang__ ) && __GNUC__ < 7
113
# define BIT7Z_DEPRECATED_TYPEDEF( alias_name, alias_value, msg ) \
114
using alias_name BIT7Z_MAYBE_UNUSED __attribute__(( __deprecated__( msg ) )) = alias_value
115
# else
116
# define BIT7Z_DEPRECATED_TYPEDEF( alias_name, alias_value, msg ) \
117
using alias_name BIT7Z_MAYBE_UNUSED BIT7Z_DEPRECATED_MSG( msg ) = alias_value
118
# endif
119
#endif
120
121
#endif
//BITDEFINES_HPP
include
bit7z
bitdefines.hpp
Generated by
1.12.0