ucx/cx/common.h

changeset 21
5ea41679e15d
parent 16
04c9f8d8f03b
child 22
112b85020dc9
equal deleted inserted replaced
20:6cfda23ae154 21:5ea41679e15d
44 * 44 *
45 * <p> 45 * <p>
46 * Repositories:<br> 46 * Repositories:<br>
47 * <a href="https://sourceforge.net/p/ucx/code">https://sourceforge.net/p/ucx/code</a> 47 * <a href="https://sourceforge.net/p/ucx/code">https://sourceforge.net/p/ucx/code</a>
48 * -&nbsp;or&nbsp;- 48 * -&nbsp;or&nbsp;-
49 * <a href="https://develop.uap-core.de/hg/ucx">https://develop.uap-core.de/hg/ucx</a> 49 * <a href="https://uap-core.de/hg/ucx">https://uap-core.de/hg/ucx</a>
50 * </p> 50 * </p>
51 * 51 *
52 * <h2>LICENCE</h2> 52 * <h2>LICENCE</h2>
53 * 53 *
54 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. 54 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
148 /** 148 /**
149 * The attributed function always returns freshly allocated memory. 149 * The attributed function always returns freshly allocated memory.
150 */ 150 */
151 #define cx_attr_malloc __attribute__((__malloc__)) 151 #define cx_attr_malloc __attribute__((__malloc__))
152 152
153 #ifndef __clang__ 153 #if !defined(__clang__) && __GNUC__ >= 11
154 /** 154 /**
155 * The pointer returned by the attributed function is supposed to be freed 155 * The pointer returned by the attributed function is supposed to be freed
156 * by @p freefunc. 156 * by @p freefunc.
157 * 157 *
158 * @param freefunc the function that shall be used to free the memory 158 * @param freefunc the function that shall be used to free the memory
238 * Takes one or two arguments: the index of the pointer and (optionally) the 238 * Takes one or two arguments: the index of the pointer and (optionally) the
239 * index of another argument specifying the maximum number of accessed bytes. 239 * index of another argument specifying the maximum number of accessed bytes.
240 */ 240 */
241 #define cx_attr_access_w(...) cx_attr_access(__write_only__, __VA_ARGS__) 241 #define cx_attr_access_w(...) cx_attr_access(__write_only__, __VA_ARGS__)
242 242
243 #if __STDC_VERSION__ >= 202300L
244
245 /** 243 /**
246 * Do not warn about unused variable. 244 * Do not warn about unused variable.
247 */ 245 */
248 #define cx_attr_unused [[maybe_unused]] 246 #define cx_attr_unused __attribute__((__unused__))
249 247
250 /** 248 /**
251 * Warn about discarded return value. 249 * Warn about discarded return value.
252 */ 250 */
253 #define cx_attr_nodiscard [[nodiscard]]
254
255 #else // no C23
256
257 /**
258 * Do not warn about unused variable.
259 */
260 #define cx_attr_unused __attribute__((__unused__))
261
262 /**
263 * Warn about discarded return value.
264 */
265 #define cx_attr_nodiscard __attribute__((__warn_unused_result__)) 251 #define cx_attr_nodiscard __attribute__((__warn_unused_result__))
266
267 #endif // __STDC_VERSION__
268 252
269 253
270 // --------------------------------------------------------------------------- 254 // ---------------------------------------------------------------------------
271 // MSVC specifics 255 // MSVC specifics
272 // --------------------------------------------------------------------------- 256 // ---------------------------------------------------------------------------

mercurial