Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
83671c05
Commit
83671c05
authored
Nov 17, 2014
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't rely on non-standard 'INT32_MAX' / 'INT32_MIN'.
Define safe constants to use when padding enums. Fixes #80.
parent
faf581d2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
5 deletions
+20
-5
cpp_enum.cc
src/google/protobuf/compiler/cpp/cpp_enum.cc
+2
-2
cpp_file.cc
src/google/protobuf/compiler/cpp/cpp_file.cc
+6
-1
plugin.pb.h
src/google/protobuf/compiler/plugin.pb.h
+6
-1
descriptor.pb.h
src/google/protobuf/descriptor.pb.h
+6
-1
No files found.
src/google/protobuf/compiler/cpp/cpp_enum.cc
View file @
83671c05
...
...
@@ -106,8 +106,8 @@ void EnumGenerator::GenerateDefinition(io::Printer* printer) {
// INT32_MIN and INT32_MAX
if
(
descriptor_
->
value_count
()
>
0
)
printer
->
Print
(
",
\n
"
);
printer
->
Print
(
vars
,
"$classname$_$prefix$INT_MIN_SENTINEL_DO_NOT_USE_ =
INT32
_MIN,
\n
"
"$classname$_$prefix$INT_MAX_SENTINEL_DO_NOT_USE_ =
INT32
_MAX"
);
"$classname$_$prefix$INT_MIN_SENTINEL_DO_NOT_USE_ =
PROTOBUF_ENUM
_MIN,
\n
"
"$classname$_$prefix$INT_MAX_SENTINEL_DO_NOT_USE_ =
PROTOBUF_ENUM
_MAX"
);
}
printer
->
Outdent
();
...
...
src/google/protobuf/compiler/cpp/cpp_file.cc
View file @
83671c05
...
...
@@ -105,7 +105,12 @@ void FileGenerator::GenerateHeader(io::Printer* printer) {
"#define PROTOBUF_$filename_identifier$__INCLUDED
\n
"
"
\n
"
"#include <string>
\n
"
"#include <stdint.h>
\n
"
// INT32_MIN, INT32_MAX
"#ifndef PROTOBUF_ENUM_MIN
\n
"
"#define PROTOBUF_ENUM_MIN (int32_t)0x80000000
\n
"
"#endif
\n
"
"#ifndef PROTOBUF_ENUM_MAX
\n
"
"#define PROTOBUF_ENUM_MAX (int32_t)0x7fffffff
\n
"
"#endif
\n
"
"
\n
"
,
"filename"
,
file_
->
name
(),
"filename_identifier"
,
filename_identifier
);
...
...
src/google/protobuf/compiler/plugin.pb.h
View file @
83671c05
...
...
@@ -5,7 +5,12 @@
#define PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto__INCLUDED
#include <string>
#include <stdint.h>
#ifndef PROTOBUF_ENUM_MIN
#define PROTOBUF_ENUM_MIN (int32_t)0x80000000
#endif
#ifndef PROTOBUF_ENUM_MAX
#define PROTOBUF_ENUM_MAX (int32_t)0x7fffffff
#endif
#include <google/protobuf/stubs/common.h>
...
...
src/google/protobuf/descriptor.pb.h
View file @
83671c05
...
...
@@ -5,7 +5,12 @@
#define PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto__INCLUDED
#include <string>
#include <stdint.h>
#ifndef PROTOBUF_ENUM_MIN
#define PROTOBUF_ENUM_MIN (int32_t)0x80000000
#endif
#ifndef PROTOBUF_ENUM_MAX
#define PROTOBUF_ENUM_MAX (int32_t)0x7fffffff
#endif
#include <google/protobuf/stubs/common.h>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment