aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/cpp/cpp_file.h
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2017-03-14 23:12:52 +0000
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2017-03-14 23:41:54 +0000
commit416f90939d4de58fe1a4e2489120010313183291 (patch)
tree4c879e5f8255c7d8ffbec69954042331cf1eee09 /src/google/protobuf/compiler/cpp/cpp_file.h
parent43f2db776c265a9b22500e7a67af583b2b4ce85f (diff)
Fix freebsd build.
It turns out system headers included by generated plugin.pb.h file already contains major/minor macro definitions when built on FreeBSD and we need to add #undefs to the generated header file. This change also fixes another compile error regarding EXPECT_DEATH on FreeBSD.
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_file.h')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_file.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_file.h b/src/google/protobuf/compiler/cpp/cpp_file.h
index 25d6eabf..e3fbb96d 100644
--- a/src/google/protobuf/compiler/cpp/cpp_file.h
+++ b/src/google/protobuf/compiler/cpp/cpp_file.h
@@ -133,6 +133,15 @@ class FileGenerator {
void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer);
+ // Sometimes the names we use in a .proto file happen to be defined as macros
+ // on some platforms (e.g., macro/minor used in plugin.proto are defined as
+ // macros in sys/types.h on FreeBSD and a few other platforms). To make the
+ // generated code compile on these platforms, we either have to undef the
+ // macro for these few platforms, or rename the field name for all platforms.
+ // Since these names are part of protobuf public API, renaming is generally
+ // a breaking change so we prefer the #undef approach.
+ void GenerateMacroUndefs(io::Printer* printer);
+
const FileDescriptor* file_;
const Options options_;