Ruby: include/ruby/backward/2/attributes.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros
attributes.h File Reference

Various attribute-related macros. More...

`#include "ruby/internal/config.h"`
`#include "ruby/internal/attr/alloc_size.h"`
`#include "ruby/internal/attr/cold.h"`
`#include "ruby/internal/attr/const.h"`
`#include "ruby/internal/attr/deprecated.h"`
`#include "ruby/internal/attr/error.h"`
`#include "ruby/internal/attr/forceinline.h"`
`#include "ruby/internal/attr/format.h"`
`#include "ruby/internal/attr/maybe_unused.h"`
`#include "ruby/internal/attr/noinline.h"`
`#include "ruby/internal/attr/nonnull.h"`
`#include "ruby/internal/attr/noreturn.h"`
`#include "ruby/internal/attr/pure.h"`
`#include "ruby/internal/attr/restrict.h"`
`#include "ruby/internal/attr/returns_nonnull.h"`
`#include "ruby/internal/attr/warning.h"`
`#include "ruby/internal/has/attribute.h"`

Go to the source code of this file.

## Macros
#define | CONSTFUNC(x) RBIMPL_ATTR_CONST() x
#define | PUREFUNC(x) RBIMPL_ATTR_PURE() x
#define | DEPRECATED(x) RBIMPL_ATTR_DEPRECATED(("")) x
#define | DEPRECATED_BY(n, x) RBIMPL_ATTR_DEPRECATED(("by: " # n)) x
#define | DEPRECATED_TYPE(mesg, decl)
#define | RUBY_CXX_DEPRECATED(mseg) RBIMPL_ATTR_DEPRECATED((mseg))
#define | NOINLINE(x) RBIMPL_ATTR_NOINLINE() x
#define | ALWAYS_INLINE(x) RBIMPL_ATTR_FORCEINLINE() x
#define | ERRORFUNC(mesg, x) RBIMPL_ATTR_ERROR(mesg) x
#define | HAVE_ATTRIBUTE_ERRORFUNC 0
#define | WARNINGFUNC(mesg, x) RBIMPL_ATTR_WARNING(mesg) x
#define | HAVE_ATTRIBUTE_WARNINGFUNC 0
#define | COLDFUNC RBIMPL_ATTR_COLD()
#define | PRINTF_ARGS(decl, string_index, first_to_check)
#define | RUBY_ATTR_ALLOC_SIZE RBIMPL_ATTR_ALLOC_SIZE
#define | RUBY_ATTR_MALLOC RBIMPL_ATTR_RESTRICT()
#define | RUBY_ATTR_RETURNS_NONNULL RBIMPL_ATTR_RETURNS_NONNULL()
#define | FUNC_MINIMIZED(x) x
#define | FUNC_UNOPTIMIZED(x) x
#define | RUBY_ALIAS_FUNCTION_TYPE(type, prot, name, args) FUNC_MINIMIZED(type prot) {return (type)name args;}
#define | RUBY_ALIAS_FUNCTION_VOID(prot, name, args) FUNC_MINIMIZED(void prot) {name args;}
#define | RUBY_ALIAS_FUNCTION(prot, name, args) RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
#define | RUBY_FUNC_NONNULL(n, x) RBIMPL_ATTR_NONNULL(n) x
#define | NORETURN(x) RBIMPL_ATTR_NORETURN() x
#define | NORETURN_STYLE_NEW
#define | PACKED_STRUCT(x) x
#define | PACKED_STRUCT_UNALIGNED(x) x
#define | RB_UNUSED_VAR(x) x RBIMPL_ATTR_MAYBE_UNUSED()

## Detailed Description

Various attribute-related macros.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

### Q&A

- Q: Why are the macros defined in this header file so inconsistent in style?
- A: Don't know. Don't blame me. Backward compatibility is the key here. I'm just preserving what they have been.

Definition in file attributes.h.

## Macro Definition Documentation

## ◆ ALWAYS_INLINE

#define ALWAYS_INLINE | ( |  | x | ) | RBIMPL_ATTR_FORCEINLINE() x

Definition at line 86 of file attributes.h.

## ◆ COLDFUNC

#define COLDFUNC RBIMPL_ATTR_COLD()

Definition at line 110 of file attributes.h.

## ◆ CONSTFUNC

#define CONSTFUNC | ( |  | x | ) | RBIMPL_ATTR_CONST() x

Definition at line 51 of file attributes.h.

## ◆ DEPRECATED

#define DEPRECATED | ( |  | x | ) | RBIMPL_ATTR_DEPRECATED(("")) x

Definition at line 57 of file attributes.h.

## ◆ DEPRECATED_BY

#define DEPRECATED_BY | ( |  | n,
|  |  | x
| ) |  | RBIMPL_ATTR_DEPRECATED(("by: " # n)) x

Definition at line 60 of file attributes.h.

## ◆ DEPRECATED_TYPE

#define DEPRECATED_TYPE | ( |  | mesg,
|  |  | decl
| ) |  |

Value:
_Pragma("message \"DEPRECATED_TYPE is deprecated\""); \
decl RBIMPL_ATTR_DEPRECATED(mseg)
RBIMPL_ATTR_DEPRECATED
#define RBIMPL_ATTR_DEPRECATED(msg)
Wraps (or simulates) [[deprecated]]
Definition: deprecated.h:60

Definition at line 64 of file attributes.h.

## ◆ ERRORFUNC

#define ERRORFUNC | ( |  | mesg,
|  |  | x
| ) |  | RBIMPL_ATTR_ERROR(mesg) x

Definition at line 90 of file attributes.h.

## ◆ FUNC_MINIMIZED

#define FUNC_MINIMIZED | ( |  | x | ) | x

Definition at line 126 of file attributes.h.

## ◆ FUNC_UNOPTIMIZED

#define FUNC_UNOPTIMIZED | ( |  | x | ) | x

Definition at line 130 of file attributes.h.

## ◆ HAVE_ATTRIBUTE_ERRORFUNC

#define HAVE_ATTRIBUTE_ERRORFUNC 0

Definition at line 94 of file attributes.h.

## ◆ HAVE_ATTRIBUTE_WARNINGFUNC

#define HAVE_ATTRIBUTE_WARNINGFUNC 0

Definition at line 102 of file attributes.h.

## ◆ NOINLINE

#define NOINLINE | ( |  | x | ) | RBIMPL_ATTR_NOINLINE() x

Definition at line 82 of file attributes.h.

## ◆ NORETURN

#define NORETURN | ( |  | x | ) | RBIMPL_ATTR_NORETURN() x

Definition at line 152 of file attributes.h.

## ◆ NORETURN_STYLE_NEW

#define NORETURN_STYLE_NEW

Definition at line 153 of file attributes.h.

## ◆ PACKED_STRUCT

#define PACKED_STRUCT | ( |  | x | ) | x

Definition at line 156 of file attributes.h.

## ◆ PACKED_STRUCT_UNALIGNED

#define PACKED_STRUCT_UNALIGNED | ( |  | x | ) | x

Definition at line 163 of file attributes.h.

## ◆ PRINTF_ARGS

#define PRINTF_ARGS | ( |  | decl,
|  |  | string_index,
|  |  | first_to_check
| ) |  |

Value:
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, (string_index), (first_to_check)) \
decl
RBIMPL_PRINTF_FORMAT
#define RBIMPL_PRINTF_FORMAT
Definition: format.h:35
RBIMPL_ATTR_FORMAT
#define RBIMPL_ATTR_FORMAT(x, y, z)
Wraps (or simulates) __attribute__((format))
Definition: format.h:29

Definition at line 112 of file attributes.h.

## ◆ PUREFUNC

#define PUREFUNC | ( |  | x | ) | RBIMPL_ATTR_PURE() x

Definition at line 54 of file attributes.h.

## ◆ RB_UNUSED_VAR

#define RB_UNUSED_VAR | ( |  | x | ) | x RBIMPL_ATTR_MAYBE_UNUSED()

Definition at line 168 of file attributes.h.

## ◆ RUBY_ALIAS_FUNCTION

#define RUBY_ALIAS_FUNCTION | ( |  | prot,
|  |  | name,
|  |  | args
| ) |  | RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)

Definition at line 144 of file attributes.h.

## ◆ RUBY_ALIAS_FUNCTION_TYPE

#define RUBY_ALIAS_FUNCTION_TYPE | ( |  | type,
|  |  | prot,
|  |  | name,
|  |  | args
| ) |  | FUNC_MINIMIZED(type prot) {return (type)name args;}

Definition at line 134 of file attributes.h.

## ◆ RUBY_ALIAS_FUNCTION_VOID

#define RUBY_ALIAS_FUNCTION_VOID | ( |  | prot,
|  |  | name,
|  |  | args
| ) |  | FUNC_MINIMIZED(void prot) {name args;}

Definition at line 139 of file attributes.h.

## ◆ RUBY_ATTR_ALLOC_SIZE

#define RUBY_ATTR_ALLOC_SIZE RBIMPL_ATTR_ALLOC_SIZE

Definition at line 117 of file attributes.h.

## ◆ RUBY_ATTR_MALLOC

#define RUBY_ATTR_MALLOC RBIMPL_ATTR_RESTRICT()

Definition at line 120 of file attributes.h.

## ◆ RUBY_ATTR_RETURNS_NONNULL

#define RUBY_ATTR_RETURNS_NONNULL RBIMPL_ATTR_RETURNS_NONNULL()

Definition at line 123 of file attributes.h.

## ◆ RUBY_CXX_DEPRECATED

#define RUBY_CXX_DEPRECATED | ( |  | mseg | ) | RBIMPL_ATTR_DEPRECATED((mseg))

Definition at line 79 of file attributes.h.

## ◆ RUBY_FUNC_NONNULL

#define RUBY_FUNC_NONNULL | ( |  | n,
|  |  | x
| ) |  | RBIMPL_ATTR_NONNULL(n) x

Definition at line 149 of file attributes.h.

## ◆ WARNINGFUNC

#define WARNINGFUNC | ( |  | mesg,
|  |  | x
| ) |  | RBIMPL_ATTR_WARNING(mesg) x

Definition at line 98 of file attributes.h.