You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

port_def.inc 34 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. // This file defines common macros that are used in protobuf.
  31. //
  32. // To hide these definitions from the outside world (and to prevent collisions
  33. // if more than one version of protobuf is #included in the same project) you
  34. // must follow this pattern when #including port_def.inc in a header file:
  35. //
  36. // #include "other_header.h"
  37. // #include "message.h"
  38. // // etc.
  39. //
  40. // #include "port_def.inc" // MUST be last header included
  41. //
  42. // // Definitions for this header.
  43. //
  44. // #include "port_undef.inc"
  45. //
  46. // This is a textual header with no include guard, because we want to
  47. // detect/prohibit anytime it is #included twice without a corresponding
  48. // #undef.
  49. // The definitions in this file are intended to be portable across Clang,
  50. // GCC, and MSVC. Function-like macros are usable without an #ifdef guard.
  51. // Syntax macros (for example, attributes) are always defined, although
  52. // they may be empty.
  53. //
  54. // Some definitions rely on the NDEBUG macro and/or (in MSVC) _DEBUG:
  55. // - https://en.cppreference.com/w/c/error/assert
  56. // - https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros#microsoft-specific-predefined-macros
  57. //
  58. // References for predefined macros:
  59. // - Standard: https://en.cppreference.com/w/cpp/preprocessor/replace
  60. // - Clang: https://clang.llvm.org/docs/LanguageExtensions.html
  61. // (see also GCC predefined macros)
  62. // - GCC: https://gcc.gnu.org/onlinedocs/cpp/Predefined-Macros.html
  63. // - MSVC: https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
  64. // - Interactive (Clang/GCC only): https://www.compiler-explorer.com/z/hc6jKd3sj
  65. //
  66. // References for attributes (and extension attributes):
  67. // - Standard: https://en.cppreference.com/w/cpp/language/attributes
  68. // - Clang: https://clang.llvm.org/docs/AttributeReference.html
  69. // - GCC: https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
  70. // (see Clang attribute docs as well)
  71. //
  72. // References for standard C++ language conformance (and minimum versions):
  73. // - Clang: https://clang.llvm.org/cxx_status.html
  74. // - GCC: https://gcc.gnu.org/projects/cxx-status.html
  75. // - MSVC: https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance
  76. //
  77. // Historical release notes (which can help to determine minimum versions):
  78. // - Clang: https://releases.llvm.org/
  79. // - GCC: https://gcc.gnu.org/releases.html
  80. // - MSVC: https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-history
  81. // https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes-history
  82. // Portable fallbacks for C++20 feature test macros:
  83. // https://en.cppreference.com/w/cpp/feature_test
  84. #ifndef __has_cpp_attribute
  85. #define __has_cpp_attribute(x) 0
  86. #define PROTOBUF_has_cpp_attribute_DEFINED_
  87. #endif
  88. // Portable fallback for Clang's __has_feature macro:
  89. // https://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
  90. #ifndef __has_feature
  91. #define __has_feature(x) 0
  92. #define PROTOBUF_has_feature_DEFINED_
  93. #endif
  94. // Portable fallback for Clang's __has_warning macro:
  95. #ifndef __has_warning
  96. #define __has_warning(x) 0
  97. #define PROTOBUF_has_warning_DEFINED_
  98. #endif
  99. // Portable fallbacks for the __has_attribute macro (GCC and Clang):
  100. // https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
  101. // https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html
  102. #ifndef __has_attribute
  103. #define __has_attribute(x) 0
  104. #define PROTOBUF_has_attribute_DEFINED_
  105. #endif
  106. // Portable fallback for __has_builtin (GCC and Clang):
  107. // https://clang.llvm.org/docs/LanguageExtensions.html#has-builtin
  108. // https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fbuiltin.html
  109. #ifndef __has_builtin
  110. #define __has_builtin(x) 0
  111. #define PROTOBUF_has_builtin_DEFINED_
  112. #endif
  113. // Portable PROTOBUF_BUILTIN_BSWAPxx definitions
  114. // Code must check for availability, e.g.: `defined(PROTOBUF_BUILTIN_BSWAP32)`
  115. #ifdef PROTOBUF_BUILTIN_BSWAP16
  116. #error PROTOBUF_BUILTIN_BSWAP16 was previously defined
  117. #endif
  118. #ifdef PROTOBUF_BUILTIN_BSWAP32
  119. #error PROTOBUF_BUILTIN_BSWAP32 was previously defined
  120. #endif
  121. #ifdef PROTOBUF_BUILTIN_BSWAP64
  122. #error PROTOBUF_BUILTIN_BSWAP64 was previously defined
  123. #endif
  124. #if defined(__GNUC__) || __has_builtin(__builtin_bswap16)
  125. #define PROTOBUF_BUILTIN_BSWAP16(x) __builtin_bswap16(x)
  126. #endif
  127. #if defined(__GNUC__) || __has_builtin(__builtin_bswap32)
  128. #define PROTOBUF_BUILTIN_BSWAP32(x) __builtin_bswap32(x)
  129. #endif
  130. #if defined(__GNUC__) || __has_builtin(__builtin_bswap64)
  131. #define PROTOBUF_BUILTIN_BSWAP64(x) __builtin_bswap64(x)
  132. #endif
  133. // Portable check for GCC minimum version:
  134. // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
  135. #if defined(__GNUC__) && defined(__GNUC_MINOR__) \
  136. && defined(__GNUC_PATCHLEVEL__)
  137. # define PROTOBUF_GNUC_MIN(x, y) \
  138. (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
  139. #else
  140. # define PROTOBUF_GNUC_MIN(x, y) 0
  141. #endif
  142. // Portable check for MSVC minimum version:
  143. // https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
  144. #if defined(_MSC_VER)
  145. #define PROTOBUF_MSC_VER_MIN(x) (_MSC_VER >= x)
  146. #else
  147. #define PROTOBUF_MSC_VER_MIN(x) 0
  148. #endif
  149. // Portable check for minimum C++ language version:
  150. // https://en.cppreference.com/w/cpp/preprocessor/replace
  151. // https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
  152. #if !defined(_MSVC_LANG)
  153. #define PROTOBUF_CPLUSPLUS_MIN(x) (__cplusplus >= x)
  154. #else
  155. #define PROTOBUF_CPLUSPLUS_MIN(x) (_MSVC_LANG >= x)
  156. #endif
  157. // Future versions of protobuf will include breaking changes to some APIs.
  158. // This macro can be set to enable these API changes ahead of time, so that
  159. // user code can be updated before upgrading versions of protobuf.
  160. // PROTOBUF_FUTURE_FINAL is used on classes that are historically not marked as
  161. // final, but that may be marked final in future (breaking) releases.
  162. // #define PROTOBUF_FUTURE_BREAKING_CHANGES 1
  163. // #define PROTOBUF_FUTURE_FINAL final
  164. #define PROTOBUF_FUTURE_FINAL
  165. #ifdef PROTOBUF_VERSION
  166. #error PROTOBUF_VERSION was previously defined
  167. #endif
  168. #define PROTOBUF_VERSION 3021006
  169. #ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
  170. #error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined
  171. #endif
  172. #define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 3021000
  173. #ifdef PROTOBUF_MIN_PROTOC_VERSION
  174. #error PROTOBUF_MIN_PROTOC_VERSION was previously defined
  175. #endif
  176. #define PROTOBUF_MIN_PROTOC_VERSION 3021000
  177. #ifdef PROTOBUF_VERSION_SUFFIX
  178. #error PROTOBUF_VERSION_SUFFIX was previously defined
  179. #endif
  180. #define PROTOBUF_VERSION_SUFFIX ""
  181. #if defined(PROTOBUF_NAMESPACE) || defined(PROTOBUF_NAMESPACE_ID)
  182. #error PROTOBUF_NAMESPACE or PROTOBUF_NAMESPACE_ID was previously defined
  183. #endif
  184. #define PROTOBUF_NAMESPACE "google::protobuf"
  185. #define PROTOBUF_NAMESPACE_ID google::protobuf
  186. #define PROTOBUF_NAMESPACE_OPEN \
  187. namespace google { \
  188. namespace protobuf {
  189. #define PROTOBUF_NAMESPACE_CLOSE \
  190. } /* namespace protobuf */ \
  191. } /* namespace google */
  192. #ifdef PROTOBUF_ALWAYS_INLINE
  193. #error PROTOBUF_ALWAYS_INLINE was previously defined
  194. #endif
  195. // For functions we want to force inline.
  196. #if defined(PROTOBUF_NO_INLINE)
  197. # define PROTOBUF_ALWAYS_INLINE
  198. #elif PROTOBUF_GNUC_MIN(3, 1)
  199. # define PROTOBUF_ALWAYS_INLINE __attribute__((always_inline))
  200. #elif defined(_MSC_VER)
  201. # define PROTOBUF_ALWAYS_INLINE __forceinline
  202. #else
  203. # define PROTOBUF_ALWAYS_INLINE
  204. #endif
  205. #ifdef PROTOBUF_NDEBUG_INLINE
  206. #error PROTOBUF_NDEBUG_INLINE was previously defined
  207. #endif
  208. // Avoid excessive inlining in non-optimized builds. Without other optimizations
  209. // the inlining is not going to provide benefits anyway and the huge resulting
  210. // functions, especially in the proto-generated serialization functions, produce
  211. // stack frames so large that many tests run into stack overflows (b/32192897).
  212. #if defined(NDEBUG) || (defined(_MSC_VER) && !defined(_DEBUG))
  213. # define PROTOBUF_NDEBUG_INLINE PROTOBUF_ALWAYS_INLINE
  214. #else
  215. # define PROTOBUF_NDEBUG_INLINE
  216. #endif
  217. // Note that PROTOBUF_NOINLINE is an attribute applied to functions, to prevent
  218. // them from being inlined by the compiler. This is different from
  219. // PROTOBUF_NO_INLINE, which is a user-supplied macro that disables forced
  220. // inlining by PROTOBUF_(ALWAYS|NDEBUG)_INLINE.
  221. #ifdef PROTOBUF_NOINLINE
  222. #error PROTOBUF_NOINLINE was previously defined
  223. #endif
  224. #if PROTOBUF_GNUC_MIN(3, 1)
  225. # define PROTOBUF_NOINLINE __attribute__((noinline))
  226. #elif defined(_MSC_VER)
  227. // Seems to have been around since at least Visual Studio 2005
  228. # define PROTOBUF_NOINLINE __declspec(noinline)
  229. #endif
  230. #ifdef PROTOBUF_MUSTTAIL
  231. #error PROTOBUF_MUSTTAIL was previously defined
  232. #endif
  233. #ifdef PROTOBUF_TAILCALL
  234. #error PROTOBUF_TAILCALL was previously defined
  235. #endif
  236. #if __has_cpp_attribute(clang::musttail) && !defined(__arm__) && \
  237. !defined(_ARCH_PPC) && !defined(__wasm__) && \
  238. !(defined(_MSC_VER) && defined(_M_IX86)) && \
  239. !(defined(__NDK_MAJOR__) && __NDK_MAJOR <= 24)
  240. # ifndef PROTO2_OPENSOURCE
  241. // Compilation fails on ARM32: b/195943306
  242. // Compilation fails on powerpc64le: b/187985113
  243. // Compilation fails on X86 Windows:
  244. // https://github.com/llvm/llvm-project/issues/53271
  245. # endif
  246. #define PROTOBUF_MUSTTAIL [[clang::musttail]]
  247. #define PROTOBUF_TAILCALL true
  248. #else
  249. #define PROTOBUF_MUSTTAIL
  250. #define PROTOBUF_TAILCALL false
  251. #endif
  252. #ifdef PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED
  253. #error PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED was previously defined
  254. #endif
  255. #if __has_attribute(exclusive_locks_required)
  256. #define PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED(...) \
  257. __attribute__((exclusive_locks_required(__VA_ARGS__)))
  258. #else
  259. #define PROTOBUF_EXCLUSIVE_LOCKS_REQUIRED(...)
  260. #endif
  261. #ifdef PROTOBUF_NO_THREAD_SAFETY_ANALYSIS
  262. #error PROTOBUF_NO_THREAD_SAFETY_ANALYSIS was previously defined
  263. #endif
  264. #if __has_attribute(no_thread_safety_analysis)
  265. #define PROTOBUF_NO_THREAD_SAFETY_ANALYSIS \
  266. __attribute__((no_thread_safety_analysis))
  267. #else
  268. #define PROTOBUF_NO_THREAD_SAFETY_ANALYSIS
  269. #endif
  270. #ifdef PROTOBUF_GUARDED_BY
  271. #error PROTOBUF_GUARDED_BY was previously defined
  272. #endif
  273. #if __has_attribute(guarded_by)
  274. #define PROTOBUF_GUARDED_BY(x) __attribute__((guarded_by(x)))
  275. #else
  276. #define PROTOBUF_GUARDED_BY(x)
  277. #endif
  278. #ifdef PROTOBUF_LOCKS_EXCLUDED
  279. #error PROTOBUF_LOCKS_EXCLUDED was previously defined
  280. #endif
  281. #if __has_attribute(locks_excluded)
  282. #define PROTOBUF_LOCKS_EXCLUDED(...) \
  283. __attribute__((locks_excluded(__VA_ARGS__)))
  284. #else
  285. #define PROTOBUF_LOCKS_EXCLUDED(...)
  286. #endif
  287. #ifdef PROTOBUF_COLD
  288. #error PROTOBUF_COLD was previously defined
  289. #endif
  290. #if __has_attribute(cold) || PROTOBUF_GNUC_MIN(4, 3)
  291. # define PROTOBUF_COLD __attribute__((cold))
  292. #else
  293. # define PROTOBUF_COLD
  294. #endif
  295. #ifdef PROTOBUF_SECTION_VARIABLE
  296. #error PROTOBUF_SECTION_VARIABLE was previously defined
  297. #endif
  298. #if (__has_attribute(section) || defined(__GNUC__)) && defined(__ELF__)
  299. // Place a variable in the given ELF section.
  300. # define PROTOBUF_SECTION_VARIABLE(x) __attribute__((section(#x)))
  301. #else
  302. # define PROTOBUF_SECTION_VARIABLE(x)
  303. #endif
  304. #if defined(PROTOBUF_DEPRECATED)
  305. #error PROTOBUF_DEPRECATED was previously defined
  306. #endif
  307. #if defined(PROTOBUF_DEPRECATED_MSG)
  308. #error PROTOBUF_DEPRECATED_MSG was previously defined
  309. #endif
  310. #if __has_attribute(deprecated) || PROTOBUF_GNUC_MIN(3, 0)
  311. # define PROTOBUF_DEPRECATED __attribute__((deprecated))
  312. # define PROTOBUF_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
  313. #elif defined(_MSC_VER)
  314. # define PROTOBUF_DEPRECATED __declspec(deprecated)
  315. # define PROTOBUF_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
  316. #else
  317. # define PROTOBUF_DEPRECATED
  318. # define PROTOBUF_DEPRECATED_MSG(msg)
  319. #endif
  320. #if defined(PROTOBUF_DEPRECATED_ENUM)
  321. #error PROTOBUF_DEPRECATED_ENUM was previously defined
  322. #endif
  323. #if defined(__clang__) || PROTOBUF_GNUC_MIN(6, 0)
  324. // https://gcc.gnu.org/gcc-6/changes.html
  325. # define PROTOBUF_DEPRECATED_ENUM __attribute__((deprecated))
  326. #else
  327. # define PROTOBUF_DEPRECATED_ENUM
  328. #endif
  329. #ifdef PROTOBUF_FUNC_ALIGN
  330. #error PROTOBUF_FUNC_ALIGN was previously defined
  331. #endif
  332. #if __has_attribute(aligned) || PROTOBUF_GNUC_MIN(4, 3)
  333. #define PROTOBUF_FUNC_ALIGN(bytes) __attribute__((aligned(bytes)))
  334. #else
  335. #define PROTOBUF_FUNC_ALIGN(bytes)
  336. #endif
  337. #ifdef PROTOBUF_RETURNS_NONNULL
  338. #error PROTOBUF_RETURNS_NONNULL was previously defined
  339. #endif
  340. #if __has_attribute(returns_nonnull) || PROTOBUF_GNUC_MIN(4, 9)
  341. #define PROTOBUF_RETURNS_NONNULL __attribute__((returns_nonnull))
  342. #else
  343. #define PROTOBUF_RETURNS_NONNULL
  344. #endif
  345. #ifdef PROTOBUF_ATTRIBUTE_REINITIALIZES
  346. #error PROTOBUF_ATTRIBUTE_REINITIALIZES was previously defined
  347. #endif
  348. #if __has_cpp_attribute(clang::reinitializes)
  349. #define PROTOBUF_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]]
  350. #else
  351. #define PROTOBUF_ATTRIBUTE_REINITIALIZES
  352. #endif
  353. // The minimum library version which works with the current version of the
  354. // headers.
  355. #define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3021000
  356. #ifdef PROTOBUF_RTTI
  357. #error PROTOBUF_RTTI was previously defined
  358. #endif
  359. #if defined(GOOGLE_PROTOBUF_NO_RTTI) && GOOGLE_PROTOBUF_NO_RTTI
  360. // A user-provided definition GOOGLE_PROTOBUF_NO_RTTI=1 disables RTTI.
  361. #define PROTOBUF_RTTI 0
  362. #elif defined(__cpp_rtti)
  363. // https://en.cppreference.com/w/cpp/feature_test
  364. #define PROTOBUF_RTTI 1
  365. #elif __has_feature(cxx_rtti)
  366. // https://clang.llvm.org/docs/LanguageExtensions.html#c-rtti
  367. #define PROTOBUF_RTTI 1
  368. #elif defined(__GXX_RTTI)
  369. // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
  370. #define PROTOBUF_RTTI 1
  371. #elif defined(_CPPRTTI)
  372. // https://docs.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information
  373. #define PROTOBUF_RTTI 1
  374. #else
  375. #define PROTOBUF_RTTI 0
  376. #endif
  377. // Returns the offset of the given field within the given aggregate type.
  378. // This is equivalent to the ANSI C offsetof() macro. However, according
  379. // to the C++ standard, offsetof() only works on POD types, and GCC
  380. // enforces this requirement with a warning. In practice, this rule is
  381. // unnecessarily strict; there is probably no compiler or platform on
  382. // which the offsets of the direct fields of a class are non-constant.
  383. // Fields inherited from superclasses *can* have non-constant offsets,
  384. // but that's not what this macro will be used for.
  385. #ifdef PROTOBUF_FIELD_OFFSET
  386. #error PROTOBUF_FIELD_OFFSET was previously defined
  387. #endif
  388. #if defined(__clang__)
  389. // For Clang we use __builtin_offsetof() and suppress the warning,
  390. // to avoid Control Flow Integrity and UBSan vptr sanitizers from
  391. // crashing while trying to validate the invalid reinterpret_casts.
  392. #define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) \
  393. _Pragma("clang diagnostic push") \
  394. _Pragma("clang diagnostic ignored \"-Winvalid-offsetof\"") \
  395. __builtin_offsetof(TYPE, FIELD) \
  396. _Pragma("clang diagnostic pop")
  397. #elif PROTOBUF_GNUC_MIN(4, 8)
  398. #define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD)
  399. #else // defined(__clang__)
  400. // Note that we calculate relative to the pointer value 16 here since if we
  401. // just use zero, GCC complains about dereferencing a NULL pointer. We
  402. // choose 16 rather than some other number just in case the compiler would
  403. // be confused by an unaligned pointer.
  404. #define PROTOBUF_FIELD_OFFSET(TYPE, FIELD) \
  405. static_cast< ::uint32_t>(reinterpret_cast<const char*>( \
  406. &reinterpret_cast<const TYPE*>(16)->FIELD) - \
  407. reinterpret_cast<const char*>(16))
  408. #endif
  409. #ifdef PROTOBUF_EXPORT
  410. #error PROTOBUF_EXPORT was previously defined
  411. #endif
  412. #if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
  413. # if defined(LIBPROTOBUF_EXPORTS)
  414. # define PROTOBUF_EXPORT __declspec(dllexport)
  415. # define PROTOBUF_EXPORT_TEMPLATE_DECLARE
  416. # define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllexport)
  417. # else
  418. # define PROTOBUF_EXPORT __declspec(dllimport)
  419. # define PROTOBUF_EXPORT_TEMPLATE_DECLARE
  420. # define PROTOBUF_EXPORT_TEMPLATE_DEFINE __declspec(dllimport)
  421. # endif // defined(LIBPROTOBUF_EXPORTS)
  422. #elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOBUF_EXPORTS)
  423. # define PROTOBUF_EXPORT __attribute__((visibility("default")))
  424. # define PROTOBUF_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default")))
  425. # define PROTOBUF_EXPORT_TEMPLATE_DEFINE
  426. #else
  427. # define PROTOBUF_EXPORT
  428. # define PROTOBUF_EXPORT_TEMPLATE_DECLARE
  429. # define PROTOBUF_EXPORT_TEMPLATE_DEFINE
  430. #endif
  431. #ifdef PROTOC_EXPORT
  432. #error PROTOC_EXPORT was previously defined
  433. #endif
  434. #if defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
  435. # if defined(LIBPROTOC_EXPORTS)
  436. # define PROTOC_EXPORT __declspec(dllexport)
  437. # else
  438. # define PROTOC_EXPORT __declspec(dllimport)
  439. # endif // defined(LIBPROTOC_EXPORTS)
  440. #elif defined(PROTOBUF_USE_DLLS) && defined(LIBPROTOC_EXPORTS)
  441. # define PROTOC_EXPORT __attribute__((visibility("default")))
  442. #else
  443. # define PROTOC_EXPORT
  444. #endif
  445. #if defined(PROTOBUF_PREDICT_TRUE) || defined(PROTOBUF_PREDICT_FALSE)
  446. #error PROTOBUF_PREDICT_(TRUE|FALSE) was previously defined
  447. #endif
  448. #if PROTOBUF_GNUC_MIN(3, 0)
  449. # define PROTOBUF_PREDICT_TRUE(x) (__builtin_expect(false || (x), true))
  450. # define PROTOBUF_PREDICT_FALSE(x) (__builtin_expect(false || (x), false))
  451. #else
  452. # define PROTOBUF_PREDICT_TRUE(x) (x)
  453. # define PROTOBUF_PREDICT_FALSE(x) (x)
  454. #endif
  455. #ifdef PROTOBUF_NODISCARD
  456. #error PROTOBUF_NODISCARD was previously defined
  457. #endif
  458. #if __has_cpp_attribute(nodiscard) && PROTOBUF_CPLUSPLUS_MIN(201703L)
  459. #define PROTOBUF_NODISCARD [[nodiscard]]
  460. #elif __has_attribute(warn_unused_result) || PROTOBUF_GNUC_MIN(4, 8)
  461. #define PROTOBUF_NODISCARD __attribute__((warn_unused_result))
  462. #else
  463. #define PROTOBUF_NODISCARD
  464. #endif
  465. // Enable all stable experiments if this flag is set. This allows us to group
  466. // all of these experiments under a single build flag, which can be enabled in
  467. // the protobuf.stable-experiments TAP project.
  468. #ifdef PROTOBUF_ENABLE_STABLE_EXPERIMENTS
  469. #define PROTOBUF_FORCE_MESSAGE_OWNED_ARENA
  470. #endif // !PROTOBUF_ENABLE_STABLE_EXPERIMENTS
  471. #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE
  472. #error PROTOBUF_FORCE_COPY_IN_RELEASE was previously defined
  473. #endif
  474. #ifdef PROTOBUF_FORCE_COPY_IN_SWAP
  475. #error PROTOBUF_FORCE_COPY_IN_SWAP was previously defined
  476. #endif
  477. #ifdef PROTOBUF_FORCE_COPY_IN_MOVE
  478. #error PROTOBUF_FORCE_COPY_IN_MOVE was previously defined
  479. #endif
  480. #ifdef PROTOBUF_FORCE_RESET_IN_CLEAR
  481. #error PROTOBUF_FORCE_RESET_IN_CLEAR was previously defined
  482. #endif
  483. // Force copy the default string to a string field so that non-optimized builds
  484. // have harder-to-rely-on address stability.
  485. #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  486. #error PROTOBUF_FORCE_COPY_DEFAULT_STRING was previously defined
  487. #endif
  488. #ifdef PROTOBUF_FALLTHROUGH_INTENDED
  489. #error PROTOBUF_FALLTHROUGH_INTENDED was previously defined
  490. #endif
  491. #if __has_cpp_attribute(fallthrough)
  492. #define PROTOBUF_FALLTHROUGH_INTENDED [[fallthrough]]
  493. #elif __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
  494. #define PROTOBUF_FALLTHROUGH_INTENDED [[clang::fallthrough]]
  495. #elif PROTOBUF_GNUC_MIN(7, 0)
  496. #define PROTOBUF_FALLTHROUGH_INTENDED [[gnu::fallthrough]]
  497. #else
  498. #define PROTOBUF_FALLTHROUGH_INTENDED
  499. #endif
  500. // PROTOBUF_ASSUME(pred) tells the compiler that it can assume pred is true. To
  501. // be safe, we also validate the assumption with a GOOGLE_DCHECK in unoptimized
  502. // builds. The macro does not do anything useful if the compiler does not
  503. // support __builtin_assume.
  504. #ifdef PROTOBUF_ASSUME
  505. #error PROTOBUF_ASSUME was previously defined
  506. #endif
  507. #if __has_builtin(__builtin_assume)
  508. #define PROTOBUF_ASSUME(pred) \
  509. GOOGLE_DCHECK(pred); \
  510. __builtin_assume(pred)
  511. #else
  512. #define PROTOBUF_ASSUME(pred) GOOGLE_DCHECK(pred)
  513. #endif
  514. // Specify memory alignment for structs, classes, etc.
  515. // Use like:
  516. // class PROTOBUF_ALIGNAS(16) MyClass { ... }
  517. // PROTOBUF_ALIGNAS(16) int array[4];
  518. //
  519. // In most places you can use the C++11 keyword "alignas", which is preferred.
  520. //
  521. // But compilers have trouble mixing __attribute__((...)) syntax with
  522. // alignas(...) syntax.
  523. //
  524. // Doesn't work in clang or gcc:
  525. // struct alignas(16) __attribute__((packed)) S { char c; };
  526. // Works in clang but not gcc:
  527. // struct __attribute__((packed)) alignas(16) S2 { char c; };
  528. // Works in clang and gcc:
  529. // struct alignas(16) S3 { char c; } __attribute__((packed));
  530. //
  531. // There are also some attributes that must be specified *before* a class
  532. // definition: visibility (used for exporting functions/classes) is one of
  533. // these attributes. This means that it is not possible to use alignas() with a
  534. // class that is marked as exported.
  535. #ifdef PROTOBUF_ALIGNAS
  536. #error PROTOBUF_ALIGNAS was previously defined
  537. #endif
  538. #if defined(_MSC_VER)
  539. #define PROTOBUF_ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
  540. #elif PROTOBUF_GNUC_MIN(3, 0)
  541. #define PROTOBUF_ALIGNAS(byte_alignment) \
  542. __attribute__((aligned(byte_alignment)))
  543. #else
  544. #define PROTOBUF_ALIGNAS(byte_alignment) alignas(byte_alignment)
  545. #endif
  546. #ifdef PROTOBUF_FINAL
  547. #error PROTOBUF_FINAL was previously defined
  548. #endif
  549. #define PROTOBUF_FINAL final
  550. #ifdef PROTOBUF_THREAD_LOCAL
  551. #error PROTOBUF_THREAD_LOCAL was previously defined
  552. #endif
  553. #if defined(_MSC_VER)
  554. #define PROTOBUF_THREAD_LOCAL __declspec(thread)
  555. #else
  556. #define PROTOBUF_THREAD_LOCAL __thread
  557. #endif
  558. // TODO(b/228173843): cleanup PROTOBUF_LITTLE_ENDIAN in various 3p forks.
  559. #if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
  560. __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  561. #define PROTOBUF_LITTLE_ENDIAN 1
  562. #ifdef PROTOBUF_BIG_ENDIAN
  563. #error Conflicting PROTOBUF_BIG_ENDIAN was previously defined
  564. #endif
  565. #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
  566. __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  567. #define PROTOBUF_BIG_ENDIAN 1
  568. #elif defined(_WIN32) || defined(__x86_64__) || defined(__aarch64__)
  569. #define PROTOBUF_LITTLE_ENDIAN 1
  570. #else
  571. #error "endian detection failed for current compiler"
  572. #endif
  573. // For enabling message owned arena, one major blocker is semantic change from
  574. // moving to copying when there is ownership transfer (e.g., move ctor, swap,
  575. // set allocated, release). This change not only causes performance regression
  576. // but also breaks users code (e.g., dangling reference). For top-level
  577. // messages, since it owns the arena, we can mitigate the issue by transferring
  578. // ownership of arena. However, we cannot do that for nested messages. In order
  579. // to tell how many usages of nested messages affected by message owned arena,
  580. // we need to simulate the arena ownership.
  581. // This experiment is purely for the purpose of gathering data. All code guarded
  582. // by this flag is supposed to be removed after this experiment.
  583. #define PROTOBUF_MESSAGE_OWNED_ARENA_EXPERIMENT
  584. #ifdef PROTOBUF_CONSTINIT
  585. #error PROTOBUF_CONSTINIT was previously defined
  586. #endif
  587. #if defined(__cpp_constinit) && !defined(_MSC_VER)
  588. #define PROTOBUF_CONSTINIT constinit
  589. #define PROTOBUF_CONSTEXPR constexpr
  590. // Some older Clang versions incorrectly raise an error about
  591. // constant-initializing weak default instance pointers. Versions 12.0 and
  592. // higher seem to work, except that XCode 12.5.1 shows the error even though it
  593. // uses Clang 12.0.5.
  594. // Clang-cl on Windows raises error also.
  595. #elif !defined(_MSC_VER) && __has_cpp_attribute(clang::require_constant_initialization) && \
  596. ((defined(__APPLE__) && __clang_major__ >= 13) || \
  597. (!defined(__APPLE__) && __clang_major__ >= 12))
  598. #define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]]
  599. #define PROTOBUF_CONSTEXPR constexpr
  600. #elif PROTOBUF_GNUC_MIN(12, 2)
  601. #define PROTOBUF_CONSTINIT __constinit
  602. #define PROTOBUF_CONSTEXPR constexpr
  603. // MSVC 17 currently seems to raise an error about constant-initialized pointers.
  604. #elif defined(_MSC_VER) && _MSC_VER >= 1930
  605. #define PROTOBUF_CONSTINIT
  606. #define PROTOBUF_CONSTEXPR constexpr
  607. #else
  608. #define PROTOBUF_CONSTINIT
  609. #define PROTOBUF_CONSTEXPR
  610. #endif
  611. // Some globals with an empty non-trivial destructor are annotated with
  612. // no_destroy for performance reasons. It reduces the cost of these globals in
  613. // non-opt mode and under sanitizers.
  614. #ifdef PROTOBUF_ATTRIBUTE_NO_DESTROY
  615. #error PROTOBUF_ATTRIBUTE_NO_DESTROY was previously defined
  616. #endif
  617. #if __has_cpp_attribute(clang::no_destroy)
  618. #define PROTOBUF_ATTRIBUTE_NO_DESTROY [[clang::no_destroy]]
  619. #else
  620. #define PROTOBUF_ATTRIBUTE_NO_DESTROY
  621. #endif
  622. // Force clang to always emit complete debug info for a type.
  623. // Clang uses constructor homing to determine when to emit debug info for a
  624. // type. If the constructor of a type is never used, which can happen in some
  625. // cases where member variables are constructed in place for optimization
  626. // purposes (see b/208803175 for an example), the type will have incomplete
  627. // debug info unless this attribute is used.
  628. #ifdef PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG
  629. #error PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG was previously defined
  630. #endif
  631. #if __has_cpp_attribute(clang::standalone_debug)
  632. #define PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG [[clang::standalone_debug]]
  633. #else
  634. #define PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG
  635. #endif
  636. // Protobuf extensions and reflection require registration of the protos linked
  637. // in the binary. Not until everything is registered does the runtime have a
  638. // complete view on all protos. When code is using reflection or extensions
  639. // in between registration calls this can lead to surprising behavior. By
  640. // having the registration run first we mitigate this scenario.
  641. // Highest priority is 101. We use 102 for registration, to allow code that
  642. // really wants to higher priority to still beat us. Some initialization happens
  643. // at higher priority, though, since it is needed before registration.
  644. #ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
  645. #error PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 was previously defined
  646. #endif
  647. #ifdef PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
  648. #error PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 was previously defined
  649. #endif
  650. #if PROTOBUF_GNUC_MIN(3, 0) && (!defined(__APPLE__) || defined(__clang__)) && \
  651. !((defined(sun) || defined(__sun)) && \
  652. (defined(__SVR4) || defined(__svr4__)))
  653. #define PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 __attribute__((init_priority((101))))
  654. #define PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 __attribute__((init_priority((102))))
  655. #else
  656. #define PROTOBUF_ATTRIBUTE_INIT_PRIORITY1
  657. #define PROTOBUF_ATTRIBUTE_INIT_PRIORITY2
  658. #endif
  659. #ifdef PROTOBUF_PRAGMA_INIT_SEG
  660. #error PROTOBUF_PRAGMA_INIT_SEG was previously defined
  661. #endif
  662. #ifdef _MSC_VER
  663. #define PROTOBUF_PRAGMA_INIT_SEG __pragma(init_seg(lib))
  664. #else
  665. #define PROTOBUF_PRAGMA_INIT_SEG
  666. #endif
  667. #ifdef PROTOBUF_ATTRIBUTE_WEAK
  668. #error PROTOBUF_ATTRIBUTE_WEAK was previously defined
  669. #endif
  670. #if __has_attribute(weak) && \
  671. !defined(__APPLE__) && \
  672. (!defined(_WIN32) || __clang_major__ < 9) && \
  673. !defined(__MINGW32__)
  674. #define PROTOBUF_ATTRIBUTE_WEAK __attribute__((weak))
  675. #define PROTOBUF_HAVE_ATTRIBUTE_WEAK 1
  676. #else
  677. #define PROTOBUF_ATTRIBUTE_WEAK
  678. #define PROTOBUF_HAVE_ATTRIBUTE_WEAK 0
  679. #endif
  680. // Macros to detect sanitizers.
  681. #ifdef PROTOBUF_ASAN
  682. #error PROTOBUF_ASAN was previously defined
  683. #endif
  684. #ifdef PROTOBUF_MSAN
  685. #error PROTOBUF_MSAN was previously defined
  686. #endif
  687. #ifdef PROTOBUF_TSAN
  688. #error PROTOBUF_TSAN was previously defined
  689. #endif
  690. #if defined(__clang__)
  691. # if __has_feature(address_sanitizer)
  692. # define PROTOBUF_ASAN 1
  693. # endif
  694. # if __has_feature(thread_sanitizer)
  695. # define PROTOBUF_TSAN 1
  696. # endif
  697. # if __has_feature(memory_sanitizer)
  698. # define PROTOBUF_MSAN 1
  699. # endif
  700. #elif PROTOBUF_GNUC_MIN(3, 0)
  701. // Double-guard is needed for -Wundef:
  702. # ifdef __SANITIZE_ADDRESS__
  703. # if __SANITIZE_ADDRESS__
  704. # define PROTOBUF_ASAN 1
  705. # endif
  706. # endif
  707. # ifdef __SANITIZE_THREAD__
  708. # if __SANITIZE_THREAD__
  709. # define PROTOBUF_TSAN 1
  710. # endif
  711. # endif
  712. #endif
  713. // Tail call table-driven parsing can be enabled by defining
  714. // PROTOBUF_EXPERIMENTAL_USE_TAIL_CALL_TABLE_PARSER at compilation time. Note
  715. // that this macro is for small-scale testing only, and is not supported.
  716. #ifdef PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED
  717. #error PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED was previously declared
  718. #endif
  719. #if defined(PROTOBUF_EXPERIMENTAL_USE_TAIL_CALL_TABLE_PARSER)
  720. #define PROTOBUF_TAIL_CALL_TABLE_PARSER_ENABLED 1
  721. #endif
  722. #define PROTOBUF_TC_PARAM_DECL \
  723. ::google::protobuf::MessageLite *msg, const char *ptr, \
  724. ::google::protobuf::internal::ParseContext *ctx, \
  725. const ::google::protobuf::internal::TcParseTableBase *table, \
  726. uint64_t hasbits, ::google::protobuf::internal::TcFieldData data
  727. #ifdef PROTOBUF_UNUSED
  728. #error PROTOBUF_UNUSED was previously defined
  729. #endif
  730. #if __has_cpp_attribute(maybe_unused) || \
  731. (PROTOBUF_MSC_VER_MIN(1911) && PROTOBUF_CPLUSPLUS_MIN(201703L))
  732. #define PROTOBUF_UNUSED [[maybe_unused]]
  733. #elif __has_attribute(unused) || PROTOBUF_GNUC_MIN(3, 0)
  734. #define PROTOBUF_UNUSED __attribute__((__unused__))
  735. #else
  736. #define PROTOBUF_UNUSED
  737. #endif
  738. // ThreadSafeArenaz is turned off completely in opensource builds.
  739. // Windows declares several inconvenient macro names. We #undef them and then
  740. // restore them in port_undef.inc.
  741. #ifdef _MSC_VER
  742. #pragma push_macro("CREATE_NEW")
  743. #undef CREATE_NEW
  744. #pragma push_macro("DELETE")
  745. #undef DELETE
  746. #pragma push_macro("DOUBLE_CLICK")
  747. #undef DOUBLE_CLICK
  748. #pragma push_macro("ERROR")
  749. #undef ERROR
  750. #pragma push_macro("ERROR_BUSY")
  751. #undef ERROR_BUSY
  752. #pragma push_macro("ERROR_INSTALL_FAILED")
  753. #undef ERROR_INSTALL_FAILED
  754. #pragma push_macro("ERROR_NOT_FOUND")
  755. #undef ERROR_NOT_FOUND
  756. #pragma push_macro("GetClassName")
  757. #undef GetClassName
  758. #pragma push_macro("GetMessage")
  759. #undef GetMessage
  760. #pragma push_macro("GetObject")
  761. #undef GetObject
  762. #pragma push_macro("IGNORE")
  763. #undef IGNORE
  764. #pragma push_macro("IN")
  765. #undef IN
  766. #pragma push_macro("INPUT_KEYBOARD")
  767. #undef INPUT_KEYBOARD
  768. #pragma push_macro("NO_ERROR")
  769. #undef NO_ERROR
  770. #pragma push_macro("OUT")
  771. #undef OUT
  772. #pragma push_macro("OPTIONAL")
  773. #undef OPTIONAL
  774. #pragma push_macro("min")
  775. #undef min
  776. #pragma push_macro("max")
  777. #undef max
  778. #pragma push_macro("NEAR")
  779. #undef NEAR
  780. #pragma push_macro("NO_DATA")
  781. #undef NO_DATA
  782. #pragma push_macro("REASON_UNKNOWN")
  783. #undef REASON_UNKNOWN
  784. #pragma push_macro("SERVICE_DISABLED")
  785. #undef SERVICE_DISABLED
  786. #pragma push_macro("SEVERITY_ERROR")
  787. #undef SEVERITY_ERROR
  788. #pragma push_macro("STATUS_PENDING")
  789. #undef STATUS_PENDING
  790. #pragma push_macro("STRICT")
  791. #undef STRICT
  792. #pragma push_macro("timezone")
  793. #undef timezone
  794. #endif // _MSC_VER
  795. #ifdef __APPLE__
  796. // Inconvenient macro names from usr/include/math.h in some macOS SDKs.
  797. #pragma push_macro("DOMAIN")
  798. #undef DOMAIN
  799. // Inconvenient macro names from /usr/include/mach/boolean.h in some macOS SDKs.
  800. #pragma push_macro("TRUE")
  801. #undef TRUE
  802. #pragma push_macro("FALSE")
  803. #undef FALSE
  804. // Inconvenient macro names from usr/include/sys/syslimits.h in some macOS SDKs.
  805. #pragma push_macro("UID_MAX")
  806. #undef UID_MAX
  807. #endif // __APPLE__
  808. #if defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER)
  809. // Don't let Objective-C Macros interfere with proto identifiers with the same
  810. // name.
  811. #pragma push_macro("DEBUG")
  812. #undef DEBUG
  813. #endif // defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER)
  814. #if PROTOBUF_GNUC_MIN(3, 0)
  815. // GCC does not allow disabling diagnostics within an expression:
  816. // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60875, so we disable this one
  817. // globally even though it's only used for PROTOBUF_FIELD_OFFSET.
  818. #pragma GCC diagnostic push
  819. #pragma GCC diagnostic ignored "-Winvalid-offsetof"
  820. #endif
  821. // Silence some MSVC warnings in all our code.
  822. #ifdef _MSC_VER
  823. #pragma warning(push)
  824. // For non-trivial unions
  825. #pragma warning(disable : 4582)
  826. #pragma warning(disable : 4583)
  827. // For init_seg(lib)
  828. #pragma warning(disable : 4073)
  829. // To silence the fact that we will pop this push from another file
  830. #pragma warning(disable : 5031)
  831. // Conditional expression is constant
  832. #pragma warning(disable: 4127)
  833. // decimal digit terminates octal escape sequence
  834. #pragma warning(disable: 4125)
  835. #endif
  836. // We don't want code outside port_def doing complex testing, so
  837. // remove our portable condition test macros to nudge folks away from
  838. // using it themselves.
  839. #ifdef PROTOBUF_has_cpp_attribute_DEFINED_
  840. # undef __has_cpp_attribute
  841. # undef PROTOBUF_has_cpp_attribute_DEFINED_
  842. #endif
  843. #ifdef PROTOBUF_has_feature_DEFINED_
  844. # undef __has_feature
  845. # undef PROTOBUF_has_feature_DEFINED_
  846. #endif
  847. #ifdef PROTOBUF_has_warning_DEFINED_
  848. # undef __has_warning
  849. # undef PROTOBUF_has_warning_DEFINED_
  850. #endif
  851. #ifdef PROTOBUF_has_attribute_DEFINED_
  852. # undef __has_attribute
  853. # undef PROTOBUF_has_attribute_DEFINED_
  854. #endif
  855. #ifdef PROTOBUF_has_builtin_DEFINED_
  856. # undef __has_builtin
  857. # undef PROTOBUF_has_builtin_DEFINED_
  858. #endif