src/cx/common.h

changeset 1301
f81d8b4f40c4
parent 1235
3e058f5ba5dc
equal deleted inserted replaced
1300:fcb149ee60ff 1301:f81d8b4f40c4
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