Ruby: include/ruby/internal/attr/nodiscard.h Source File

Ruby 3.4.5p51 (2025-07-16 revision 20cda200d3ce092571d0b5d342dadca69636cb0f)

nodiscard.h
Go to the documentation of this file.
1#ifndef RBIMPL_ATTR_NODISCARD_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_ATTR_NODISCARD_H
23#include "ruby/internal/has/attribute.h"
24#include "ruby/internal/has/c_attribute.h"
25#include "ruby/internal/has/cpp_attribute.h"
26
32#if RBIMPL_HAS_CPP_ATTRIBUTE(nodiscard)
33# define RBIMPL_ATTR_NODISCARD() [[nodiscard]]
34#elif RBIMPL_HAS_C_ATTRIBUTE(nodiscard)
35# define RBIMPL_ATTR_NODISCARD() [[nodiscard]]
36#elif RBIMPL_HAS_ATTRIBUTE(warn_unused_result)
37# define RBIMPL_ATTR_NODISCARD() __attribute__((__warn_unused_result__))
38#elif defined(_Check_return_)
39# /* Take SAL definition. */
40# define RBIMPL_ATTR_NODISCARD() _Check_return_
41#else
42# define RBIMPL_ATTR_NODISCARD() /* void */
43#endif
44
45#endif /* RBIMPL_ATTR_NODISCARD_H */
attribute.h
Defines RBIMPL_HAS_ATTRIBUTE.
c_attribute.h
Defines RBIMPL_HAS_C_ATTRIBUTE.
cpp_attribute.h
Defines RBIMPL_HAS_CPP_ATTRIBUTE.