stdex
Additional custom or not Standard C++ covered algorithms
Loading...
Searching...
No Matches
compat.hpp
1/*
2 SPDX-License-Identifier: MIT
3 Copyright © 2022-2024 Amebis
4*/
5
6#pragma once
7
8#include <stddef.h>
9#ifdef _WIN32
10#include "windows.h"
11#include <sal.h>
12#include <tchar.h>
13#endif
14#include <type_traits>
15
16#ifndef _In_
17#define _In_
18#endif
19#ifndef _In_bytecount_
20#define _In_bytecount_(p)
21#endif
22#ifndef _In_count_
23#define _In_count_(p)
24#endif
25#ifndef _In_opt_
26#define _In_opt_
27#endif
28#ifndef _In_opt_count_
29#define _In_opt_count_(p)
30#endif
31#ifndef _In_opt_z_count_
32#define _In_opt_z_count_(p)
33#endif
34#ifndef _In_z_
35#define _In_z_
36#endif
37#ifndef _In_opt_z_
38#define _In_opt_z_
39#endif
40#ifndef _In_z_count_
41#define _In_z_count_(p)
42#endif
43#ifndef _In_reads_
44#define _In_reads_(p)
45#endif
46#ifndef _In_reads_bytes_
47#define _In_reads_bytes_(p)
48#endif
49#ifndef _In_reads_z_
50#define _In_reads_z_(p)
51#endif
52#ifndef _In_reads_opt_
53#define _In_reads_opt_(p)
54#endif
55#ifndef _In_reads_opt_z_
56#define _In_reads_opt_z_(p)
57#endif
58#ifndef _In_reads_or_z_
59#define _In_reads_or_z_(p)
60#endif
61#ifndef _In_reads_or_z_opt_
62#define _In_reads_or_z_opt_(p)
63#endif
64#ifndef _In_reads_bytes_opt_
65#define _In_reads_bytes_opt_(p)
66#endif
67#ifndef _Printf_format_string_
68#define _Printf_format_string_
69#endif
70#ifndef _Printf_format_string_params_
71#define _Printf_format_string_params_(n)
72#endif
73
74#ifndef _Inout_
75#define _Inout_
76#endif
77#ifndef _Inout_opt_
78#define _Inout_opt_
79#endif
80#ifndef _Inout_z_
81#define _Inout_z_
82#endif
83#ifndef _Inout_z_count_
84#define _Inout_z_count_(p)
85#endif
86#ifndef _Inout_cap_
87#define _Inout_cap_(p)
88#endif
89#ifndef _Inout_count_
90#define _Inout_count_(p)
91#endif
92#ifndef _Inout_updates_z_
93#define _Inout_updates_z_(p)
94#endif
95
96#ifndef _Use_decl_annotations_
97#define _Use_decl_annotations_
98#endif
99
100#ifndef _Out_
101#define _Out_
102#endif
103#ifndef _Out_opt_
104#define _Out_opt_
105#endif
106#ifndef _Out_z_cap_
107#define _Out_z_cap_(p)
108#endif
109#ifndef _Out_writes_
110#define _Out_writes_(p)
111#endif
112#ifndef _Out_writes_opt_
113#define _Out_writes_opt_(p)
114#endif
115#ifndef _Out_writes_all_opt_
116#define _Out_writes_all_opt_(p)
117#endif
118#ifndef _Out_writes_opt_z_
119#define _Out_writes_opt_z_(p)
120#endif
121#ifndef _Out_writes_bytes_
122#define _Out_writes_bytes_(p)
123#endif
124#ifndef _Out_writes_to_
125#define _Out_writes_to_(p, q)
126#endif
127#ifndef _Out_writes_all_
128#define _Out_writes_all_(p)
129#endif
130#ifndef _Out_writes_z_
131#define _Out_writes_z_(p)
132#endif
133#ifndef _Out_writes_bytes_to_opt_
134#define _Out_writes_bytes_to_opt_(p, q)
135#endif
136
137#ifndef _Success_
138#define _Success_(p)
139#endif
140#ifndef _Ret_maybenull_
141#define _Ret_maybenull_
142#endif
143#ifndef _Ret_maybenull_z_
144#define _Ret_maybenull_z_
145#endif
146#ifndef _Ret_notnull_
147#define _Ret_notnull_
148#endif
149#ifndef _Ret_z_
150#define _Ret_z_
151#endif
152#ifndef _Must_inspect_result_
153#define _Must_inspect_result_
154#endif
155#ifndef _Check_return_
156#define _Check_return_
157#endif
158#ifndef _Post_maybez_
159#define _Post_maybez_
160#endif
161#ifndef _Null_terminated_
162#define _Null_terminated_
163#endif
164
165#ifndef _L
166#define __L(x) L ## x
167#define _L(x) __L(x)
168#endif
169#ifndef _T
170#define _T(x) x
171#endif
172
173#ifndef _Likely_
174#if _HAS_CXX20
175#define _Likely_ [[likely]]
176#else
177#define _Likely_
178#endif
179#endif
180
181#ifndef _Unlikely_
182#if _HAS_CXX20
183#define _Unlikely_ [[unlikely]]
184#else
185#define _Unlikely_
186#endif
187#endif
188
189#ifdef _MSC_VER
190#define _Deprecated_(message) __declspec(deprecated(message))
191#define _NoReturn_ __declspec(noreturn)
192#else
193#define _Deprecated_(message) [[deprecated(message)]]
194#define _NoReturn_ [[noreturn]]
195#endif
196
197#ifdef _WIN32
198#define _Unreferenced_(x) UNREFERENCED_PARAMETER(x)
199#else
200#define _Unreferenced_(x) (void)(x)
201#endif
202
203#ifndef _WIN32
204template <class T, size_t N>
205size_t _countof(const T (&arr)[N])
206{
207 _Unreferenced_(arr);
208 return std::extent<T[N]>::value;
209}
210#endif
211
212#ifndef _Analysis_assume_
213#define _Analysis_assume_(p)
214#endif
215
216#ifdef __APPLE__
217#define off64_t off_t
218#define lseek64 lseek
219#define lockf64 lockf
220#define ftruncate64 ftruncate
221#endif