|
||||
File indexing completed on 2025-01-31 10:12:04
0001 // Protocol Buffers - Google's data interchange format 0002 // Copyright 2008 Google Inc. All rights reserved. 0003 // 0004 // Use of this source code is governed by a BSD-style 0005 // license that can be found in the LICENSE file or at 0006 // https://developers.google.com/open-source/licenses/bsd 0007 0008 // Author: kenton@google.com (Kenton Varda) and others 0009 // 0010 // Contains basic types and utilities used by the rest of the library. 0011 0012 #ifndef GOOGLE_PROTOBUF_COMMON_H__ 0013 #define GOOGLE_PROTOBUF_COMMON_H__ 0014 0015 #include <algorithm> 0016 #include <iostream> 0017 #include <memory> 0018 #include <string> 0019 #include <vector> 0020 0021 #include "absl/strings/string_view.h" 0022 #include "google/protobuf/stubs/platform_macros.h" 0023 #include "google/protobuf/stubs/port.h" 0024 0025 #if defined(__APPLE__) 0026 #include <TargetConditionals.h> // for TARGET_OS_IPHONE 0027 #endif 0028 0029 #if defined(__ANDROID__) || defined(GOOGLE_PROTOBUF_OS_ANDROID) || \ 0030 (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || \ 0031 defined(GOOGLE_PROTOBUF_OS_IPHONE) 0032 #include <pthread.h> 0033 #endif 0034 0035 #include "google/protobuf/port_def.inc" 0036 0037 namespace std {} 0038 0039 namespace google { 0040 namespace protobuf { 0041 namespace internal { 0042 0043 // Some of these constants are macros rather than const ints so that they can 0044 // be used in #if directives. 0045 0046 // The current version, represented as a single integer to make comparison 0047 // easier: major * 10^6 + minor * 10^3 + micro 0048 #define GOOGLE_PROTOBUF_VERSION 5028002 0049 0050 // A suffix string for alpha, beta or rc releases. Empty for stable releases. 0051 #define GOOGLE_PROTOBUF_VERSION_SUFFIX "" 0052 0053 // Verifies that the protobuf version a program was compiled with matches what 0054 // it is linked/running with. Use the macro below to call this function. 0055 void PROTOBUF_EXPORT VerifyVersion(int protobufVersionCompiledWith, 0056 const char* filename); 0057 0058 // Converts a numeric version number to a string. 0059 std::string PROTOBUF_EXPORT 0060 VersionString(int version); // NOLINT(runtime/string) 0061 0062 // Prints the protoc compiler version (no major version) 0063 std::string PROTOBUF_EXPORT 0064 ProtocVersionString(int version); // NOLINT(runtime/string) 0065 0066 } // namespace internal 0067 0068 // Place this macro in your main() function (or somewhere before you attempt 0069 // to use the protobuf library) to verify that the version you link against 0070 // matches the headers you compiled against. If a version mismatch is 0071 // detected, the process will abort. 0072 #define GOOGLE_PROTOBUF_VERIFY_VERSION \ 0073 ::google::protobuf::internal::VerifyVersion(GOOGLE_PROTOBUF_VERSION, __FILE__) 0074 0075 // This lives in message_lite.h now, but we leave this here for any users that 0076 // #include common.h and not message_lite.h. 0077 PROTOBUF_EXPORT void ShutdownProtobufLibrary(); 0078 0079 namespace internal { 0080 0081 // Strongly references the given variable such that the linker will be forced 0082 // to pull in this variable's translation unit. 0083 template <typename T> 0084 void StrongReference(const T& var) { 0085 auto volatile unused = &var; 0086 (void)&unused; // Use address to avoid an extra load of "unused". 0087 } 0088 0089 } // namespace internal 0090 } // namespace protobuf 0091 } // namespace google 0092 0093 #include "google/protobuf/port_undef.inc" 0094 0095 #endif // GOOGLE_PROTOBUF_COMMON_H__
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |