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

Ruby 3.3.6p108 (2024-11-05 revision 75015d4c1f6965b5e85e96fb309f1f2129f933c0)

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