Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protobuf generates header include guards using reserved names #3268

Closed
Corristo opened this issue Jun 24, 2017 · 0 comments
Closed

Protobuf generates header include guards using reserved names #3268

Corristo opened this issue Jun 24, 2017 · 0 comments
Assignees
Labels

Comments

@Corristo
Copy link

The include guards created by protobuf are of the form "PROTOBUF__2eproto__INCLUDED". However, identifiers with two consecutive underscores are reserved in C++ according to [lex.name]/3.1.

This is annoying as I'm using Clang with all warnings enabled (-Weverything) and warnings treated as errors (-Werror). It is not much of a problem to add -Wno-reserved-id-macro to the compiler flags for the protobuf generated .cc files. For my own code, however, I don't want to generically disable that warning for every file that includes protobuf headers and instead disable that warning only for the protobuf header so that I get the warning if I myself use a reserved identifier in my own code. So there are two options: Wrapping every include of a protobuf header in

#pragma GCC diagnostic push
pragma GCC diagnostic ignored "-Wreserved-id-macro"
#include <protobuf_header_here>
#pragma GCC diagnostic pop

or create my own header that is included instead of the protobuf generated header whose content is nothing but the pattern above.

Both these options aren't optimal and I'd prefer if the naming scheme for include guards is changed.

@acozzette acozzette added the c++ label Dec 11, 2017
@acozzette acozzette added this to Backlog in Fixit Q4`17 (P2 Bugs) via automation Dec 11, 2017
@xfxyjwf xfxyjwf self-assigned this Dec 13, 2017
xfxyjwf added a commit to xfxyjwf/protobuf that referenced this issue Dec 13, 2017
@xfxyjwf xfxyjwf moved this from Backlog to In progress in Fixit Q4`17 (P2 Bugs) Dec 13, 2017
Fixit Q4`17 (P2 Bugs) automation moved this from In progress to Done Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

No branches or pull requests

3 participants