Comments (16)
Btw, is it possible to allow enum entries in different enums to have the same name? just like java and C# and any modern language. I hate the error:
Note that enum values use C++ scoping rules, meaning that enum values are siblings of their type, not children of it.
from protobuf.
I think the feature most interesting for Chromium (which sleevi and I work on) are enums with underlying types, not enum classes. We want to be able to forward declare enums defined in proto.h files.
from protobuf.
Probably enum classes would also reduce Google's internal dev pains ;-)
from protobuf.
I strongly vote for the enum class feature.
Currently, I have a case where I want to print a description of the proto enum, like:
Utils.h
#include "ProtocGenerated.h"
std::string toString(ProtocGenerated::ProtoEnum protoEnum);
In order to achieve this, the protoc generated header must be included in this header - "Utils.h" - (that happens to be included in many other places), but this is not an option, so I have to change the enums from the generated headers to enum classes.
My suspicion regarding the lack of this feature is that forcing to describe the enum type size reduces the ability of protobuf to optimize the space.
from protobuf.
Has there been any process on this?
from protobuf.
I don't think we will add a C++11 compile mode. We can consider adding support for some of the individual C++11 features, though. For the enum feature, there is already a separate issue for it:
#1079
from protobuf.
I'm using the following workaround, isn't that enough?
message Foo {
enum Type {
unknown = 0;
val1 = 1;
val2 = 2;
}
}
message Test{
optional Foo.Type foo = 1;
}
In C++: Foo::val1
from protobuf.
No, because that doesn't allow forward declaring the type.
from protobuf.
@xfxyjwf Want me to file a new issue for a mode that adds enums with explicit underlying types, or do you want to reopen this one and retitle it, since that's what this issue was originally about?
from protobuf.
@nico Could you create a separate issue specifically for enum?
from protobuf.
@xfxyjwf For our build, I wanted to enable -Wsuggest-override for modern GCC. This required me to modify protobuf to add override declarations to methods, including the generated code.
I'd like to upstream those changes. Are you interested? I can either add override unconditionally or add it with a macro (which is either defined to be nothing, or to be override).
from protobuf.
@AustinSchuh Adding a PROTOBUF_OVERRIDE macro seems fine to me.
from protobuf.
@xfxyjwf , I am ready to put up a change that adds PROTOBUF_OVERRIDE, however I see PROTOBUF_FINAL has been replaced by "final" in recent change (0400cca). Is this how "override" also needs to be added now?
from protobuf.
@khuzemap We are now requiring C++11 to build protobuf master. You can just use the "override" keyword now.
from protobuf.
@xfxyjwf , have updated the change. using "override" keyword now.
from protobuf.
@xfxyjwf, wonder if you got chance to take a look at the change.
from protobuf.
Related Issues (20)
- target "libprotobuf-lite" which requires target "utf8_validity" that is not in the export set. HOT 1
- Facilitate Swift Plugin HOT 4
- protoc for Windows calls deprecated protoc-gen-go should use protoc-gen-go-grpc instead? HOT 1
- iOS Privacy manifest for Protobuf-3.19.4 HOT 1
- /usr/include/c++/11/ctime:62:11: error: ‘tm’ has not been declared in ‘::’ 62 | using ::tm; HOT 1
- Develop python package based on third-party proto
- Download protoc zip: Warnings/blocks from chrome and macOS Sonoma
- editions: how to prevent use of new "string_type" feature in edition 2023? HOT 2
- Python Collision for Enums using underscores HOT 2
- FileDescriptor's GetDebugString method(s) not present in Python API HOT 1
- java.lang.VerifyError: Bad type on operand stack after migrating HOT 2
- Macos M2 Docker image create while error occure protoc: stdout: . stderr: terminate called after throwing an instance of 'std::system_error' HOT 3
- issue with upgrade com.google.protobuf:protobuf-java to 4.26.1 HOT 2
- SerializeToArray and SerializeToOstream getting a difference result? HOT 2
- Container types are inconsistent even within the same patch of Python protobuf
- Building protobuf 27.0 with emcc yields errors HOT 2
- protoc can not generate java class
- abseil-cpp, absl in thirdparty conflict with abseil-cpp, absl in unreal5 project
- K HOT 2
- Offer a better migration path from protobuf-java 3.x to 4.x HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protobuf.