| 1 |
#ifndef RBIMPL_ATTR_DEPRECATED_H /*-*-C++-*-vi:se ft=cpp:*/ |
| 2 |
#define RBIMPL_ATTR_DEPRECATED_H |
| 3 |
/** |
| 4 |
* @file |
| 5 |
* @author Ruby developers <[email protected]> |
| 6 |
* @copyright This file is a part of the programming language Ruby. |
| 7 |
* Permission is hereby granted, to either redistribute and/or |
| 8 |
* modify this file, provided that the conditions mentioned in the |
| 9 |
* file COPYING are met. Consult the file for details. |
| 10 |
* @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are |
| 11 |
* implementation details. Don't take them as canon. They could |
| 12 |
* rapidly appear then vanish. The name (path) of this header file |
| 13 |
* is also an implementation detail. Do not expect it to persist |
| 14 |
* at the place it is now. Developers are free to move it anywhere |
| 15 |
* anytime at will. |
| 16 |
* @note To ruby-core: remember that this header can be possibly |
| 17 |
* recursively included from extension libraries written in C++. |
| 18 |
* Do not expect for instance `__VA_ARGS__` is always available. |
| 19 |
* We assume C99 for ruby itself but we don't assume languages of |
| 20 |
* extension libraries. They could be written in C++98. |
| 21 |
* @brief Defines #RBIMPL_ATTR_DEPRECATED. |
| 22 |
*/ |
| 23 |
#include "ruby/internal/compiler_since.h" |
| 24 |
#include "ruby/internal/has/attribute.h" |
| 25 |
#include "ruby/internal/has/c_attribute.h" |
| 26 |
#include "ruby/internal/has/cpp_attribute.h" |
| 27 |
#include "ruby/internal/has/declspec_attribute.h" |
| 28 |
#include "ruby/internal/has/extension.h" |
| 29 |
|
| 30 |
/** Wraps (or simulates) `[[deprecated]]` */ |
| 31 |
#if defined(__COVERITY__) |
| 32 |
/* Coverity Scan emulates gcc but seems not to support this attribute correctly */ |
| 33 |
# define RBIMPL_ATTR_DEPRECATED(msg) |
| 34 |
|
| 35 |
#elif RBIMPL_HAS_EXTENSION(attribute_deprecated_with_message) |
| 36 |
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__ msg)) |
| 37 |
|
| 38 |
#elif defined(__cplusplus) && RBIMPL_COMPILER_SINCE(GCC, 10, 1, 0) && RBIMPL_COMPILER_BEFORE(GCC, 10, 3, 0) |
| 39 |
# /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95302 */ |
| 40 |
# define RBIMPL_ATTR_DEPRECATED(msg) /* disable until they fix this bug */ |
| 41 |
|
| 42 |
#elif RBIMPL_COMPILER_SINCE(GCC, 4, 5, 0) |
| 43 |
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__ msg)) |
| 44 |
|
| 45 |
#elif RBIMPL_COMPILER_SINCE(Intel, 13, 0, 0) |
| 46 |
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__ msg)) |
| 47 |
|
| 48 |
#elif RBIMPL_HAS_ATTRIBUTE(deprecated) /* but not with message. */ |
| 49 |
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__)) |
| 50 |
|
| 51 |
#elif RBIMPL_COMPILER_SINCE(MSVC, 14, 0, 0) |
| 52 |
# define RBIMPL_ATTR_DEPRECATED(msg) __declspec(deprecated msg) |
| 53 |
|
| 54 |
#elif RBIMPL_HAS_DECLSPEC_ATTRIBUTE(deprecated) |
| 55 |
# define RBIMPL_ATTR_DEPRECATED(msg) __declspec(deprecated) |
| 56 |
|
| 57 |
#elif RBIMPL_HAS_CPP_ATTRIBUTE(deprecated) |
| 58 |
# define RBIMPL_ATTR_DEPRECATED(msg) [[deprecated msg]] |
| 59 |
|
| 60 |
#elif RBIMPL_HAS_C_ATTRIBUTE(deprecated) |
| 61 |
# define RBIMPL_ATTR_DEPRECATED(msg) [[deprecated msg]] |
| 62 |
|
| 63 |
#else |
| 64 |
# define RBIMPL_ATTR_DEPRECATED(msg) /* void */ |
| 65 |
#endif |
| 66 |
|
| 67 |
/** This is when a function is used internally (for backwards compatibility |
| 68 |
* etc.), but extension libraries must consider it deprecated. */ |
| 69 |
#if defined(RUBY_EXPORT) |
| 70 |
# define RBIMPL_ATTR_DEPRECATED_EXT(msg) /* void */ |
| 71 |
#else |
| 72 |
# define RBIMPL_ATTR_DEPRECATED_EXT(msg) RBIMPL_ATTR_DEPRECATED(msg) |
| 73 |
#endif |
| 74 |
|
| 75 |
#endif /* RBIMPL_ATTR_DEPRECATED_H */ |