Ruby: include/ruby/internal/cast.h Source File

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

cast.h
Go to the documentation of this file.
1#ifndef RBIMPL_CAST_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_CAST_H
28#include "ruby/internal/compiler_since.h"
29#include "ruby/internal/has/warning.h"
30#include "ruby/internal/warning_push.h"
31
32#if ! defined(__cplusplus)
33# define RBIMPL_CAST(expr) (expr)
34
35#elif RBIMPL_COMPILER_SINCE(GCC, 4, 6, 0)
36# /* g++ has -Wold-style-cast since 1997 or so, but its _Pragma is broken. */
37# /* See https://gcc.godbolt.org/z/XWhU6J */
38# define RBIMPL_CAST(expr) (expr)
39# pragma GCC diagnostic ignored "-Wold-style-cast"
40
41#elif RBIMPL_HAS_WARNING("-Wold-style-cast")
42# define RBIMPL_CAST(expr) \
43 RBIMPL_WARNING_PUSH() \
44 RBIMPL_WARNING_IGNORED(-Wold-style-cast) \
45 (expr) \
46 RBIMPL_WARNING_POP()
47
48#else
49# define RBIMPL_CAST(expr) (expr)
50#endif
53#endif /* RBIMPL_CAST_H */
compiler_since.h
Defines RBIMPL_COMPILER_SINCE.
warning.h
Defines RBIMPL_HAS_WARNING.
warning_push.h
Defines RBIMPL_WARNING_PUSH.