Code Monkey home page Code Monkey logo

Comments (16)

goldenbull avatar goldenbull commented on June 18, 2024 4

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.

nico avatar nico commented on June 18, 2024 1

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.

orian avatar orian commented on June 18, 2024

Probably enum classes would also reduce Google's internal dev pains ;-)

from protobuf.

alexandruirimiea avatar alexandruirimiea commented on June 18, 2024

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.

kaimast avatar kaimast commented on June 18, 2024

Has there been any process on this?

from protobuf.

xfxyjwf avatar xfxyjwf commented on June 18, 2024

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.

timotheecour avatar timotheecour commented on June 18, 2024

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.

sleevi avatar sleevi commented on June 18, 2024

No, because that doesn't allow forward declaring the type.

from protobuf.

nico avatar nico commented on June 18, 2024

@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.

xfxyjwf avatar xfxyjwf commented on June 18, 2024

@nico Could you create a separate issue specifically for enum?

from protobuf.

AustinSchuh avatar AustinSchuh commented on June 18, 2024

@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.

xfxyjwf avatar xfxyjwf commented on June 18, 2024

@AustinSchuh Adding a PROTOBUF_OVERRIDE macro seems fine to me.

from protobuf.

khuzemap avatar khuzemap commented on June 18, 2024

@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.

xfxyjwf avatar xfxyjwf commented on June 18, 2024

@khuzemap We are now requiring C++11 to build protobuf master. You can just use the "override" keyword now.

from protobuf.

khuzemap avatar khuzemap commented on June 18, 2024

@xfxyjwf , have updated the change. using "override" keyword now.

from protobuf.

khuzemap avatar khuzemap commented on June 18, 2024

@xfxyjwf, wonder if you got chance to take a look at the change.

from protobuf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.