Add UPB_DEPRECATED macro to use for deprecated field code generation.

PiperOrigin-RevId: 457996196
pull/13171/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent 16daf910cc
commit d44834063a
  1. 24
      upb/port_def.inc
  2. 2
      upb/port_undef.inc

@ -54,6 +54,15 @@
#error upb requires C99 or C++11 or MSVC >= 2015.
#endif
// Portable check for GCC minimum version:
// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
#define UPB_GNUC_MIN(x, y) \
(__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
#else
#define UPB_GNUC_MIN(x, y) 0
#endif
#include <assert.h>
#include <setjmp.h>
#include <stdbool.h>
@ -263,3 +272,18 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
#else
#define UPB_TREAT_PROTO2_ENUMS_LIKE_PROTO3 0
#endif
#if defined(__cplusplus)
#if defined(__clang__) || UPB_GNUC_MIN(6, 0)
// https://gcc.gnu.org/gcc-6/changes.html
#if __cplusplus >= 201402L
#define UPB_DEPRECATED [[deprecated]]
#else
#define UPB_DEPRECATED __attribute__((deprecated))
#endif
#else
#define UPB_DEPRECATED
#endif
#else
#define UPB_DEPRECATED
#endif

@ -61,3 +61,5 @@
#undef UPB_UNPOISON_MEMORY_REGION
#undef UPB_ASAN
#undef UPB_TREAT_PROTO2_ENUMS_LIKE_PROTO3
#undef UPB_DEPRECATED
#undef UPB_GNUC_MIN

Loading…
Cancel
Save