File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 5252# define csnip_cext_import
5353#endif
5454
55+ /** More portable version of C23's [[nodiscard]].
56+ *
57+ * For the common pre-C23 compilers, it uses a compiler-specific
58+ * alternative.
59+ */
60+ #if __STDC_VERSION >= 202311L
61+ # define csnip_cext_nodiscard [[nodiscard]]
62+ #elif defined(__GNUC__ ) || defined(__clang__ )
63+ # define csnip_cext_nodiscard __attribute__((warn_unused_result))
64+ #elif defined(_MSC_VER )
65+ # define csnip_cext_nodiscard _Check_return_
66+ #else
67+ # define csnip_cext_nodiscard /* nothing */
68+ #endif
69+
5570/**@}*/
5671
5772#endif /* CSNIP_CEXT_H */
6075#define cext_unused csnip_cext_unused
6176#define cext_export csnip_cext_export
6277#define cext_import csnip_cext_import
78+ #define cext_nodiscard csnip_cext_nodiscard
6379#define CSNIP_CEXT_HAVE_SHORT_NAMES
6480#endif /* CSNIP_SHORT_NAMES && !CSNIP_CEXT_HAVE_SHORT_NAMES */
You can’t perform that action at this time.
0 commit comments