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

name conflict in files generated from rpc.proto #625

Closed
MeatBoy106 opened this issue Feb 20, 2019 · 10 comments
Closed

name conflict in files generated from rpc.proto #625

MeatBoy106 opened this issue Feb 20, 2019 · 10 comments
Labels

Comments

@MeatBoy106
Copy link

The field minor and major of the criu_version message conflict with macros defined in system header giving the following error :

***/rpc.pb.h:2920:13: warning: In the GNU C Library, "major" is defined
by <sys/sysmacros.h>. For historical compatibility, it is
currently defined by <sys/types.h> as well, but we plan to
remove this soon. To use "major", include <sys/sysmacros.h>
directly. If you did not intend to use a system-defined macro
"major", you should undefine it after including <sys/types.h>.
::google::protobuf::int32 major() const;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Undefining these macros before including the file is not good enough to me ;)

@adrianreber
Copy link
Member

Could you provide some more details about what you are trying to do? Maybe also the steps you took to get this error.

@MeatBoy106
Copy link
Author

To reproduce the issue:

  1. Use ubuntu 18.04
  2. Use gcc 7.3 (the default one on ubuntu 18.04)
  3. Generate the C++ sources from rpc.proto using protoc (version >= 3.0.0)
  4. Compile rpc.pb.cc

This will give you a bunch of the error message cited above.
This is caused by the fields major and minor of the criu_version message which share their names with macros defined by sys/sysmacros.h.

@adrianreber
Copy link
Member

Thanks, this has been reported in other projects already:

protocolbuffers/protobuf#4654
google/gapid#1995

It seems others have just renamed those fields. Not sure we can do that easily as it would break RPC clients.

@adrianreber
Copy link
Member

Thinking more about it, this should actually be easy to solve as the names are not really important in protobuf, as long as the ID of those properties does not change it should be easy to change it.

For external RPC users we change the protobuf definitions and the corresponding code using it whenever it is necessary, but the communication between CRIU and its RPC clients should always keep working.

@MeatBoy106
Copy link
Author

MeatBoy106 commented Feb 21, 2019 via email

@adrianreber
Copy link
Member

This changes will require code changes to everyone using our protobuf RPC definition. It will not break running programs, even if CRIU is updated, but compilation will fail. So kind of an API break without breaking ABI... (I hope I understand protobuf correctly).

@MeatBoy106
Copy link
Author

MeatBoy106 commented Feb 21, 2019 via email

@adrianreber
Copy link
Member

Yes, that is also how I understand it. I will prepare a patch and hopefully this will be part of the next release if no one sees any other problems with this approach.

adrianreber added a commit to adrianreber/criu that referenced this issue Feb 26, 2019
In rpc.proto the interface to query the CRIU version number uses major
and minor as keywords. This creates errors when using the RPC
definitions with C++: checkpoint-restore#625

In this commit the fields are renamed from major to major_number and
from minor to minor_number.

For existing programs using the RPC protobuf definition this should be a
transparent change. Only for programs importing the latest rpc.proto it
will require code changes.

Signed-off-by: Adrian Reber <areber@redhat.com>
avagin pushed a commit that referenced this issue Mar 4, 2019
In rpc.proto the interface to query the CRIU version number uses major
and minor as keywords. This creates errors when using the RPC
definitions with C++: #625

In this commit the fields are renamed from major to major_number and
from minor to minor_number.

For existing programs using the RPC protobuf definition this should be a
transparent change. Only for programs importing the latest rpc.proto it
will require code changes.

Signed-off-by: Adrian Reber <areber@redhat.com>
@avagin
Copy link
Member

avagin commented Mar 7, 2019

Should we close this issue?

@avagin avagin added the bug label Mar 7, 2019
@MeatBoy106
Copy link
Author

Done, thanks for your work !

avagin pushed a commit to avagin/criu that referenced this issue Apr 16, 2019
In rpc.proto the interface to query the CRIU version number uses major
and minor as keywords. This creates errors when using the RPC
definitions with C++: checkpoint-restore#625

In this commit the fields are renamed from major to major_number and
from minor to minor_number.

For existing programs using the RPC protobuf definition this should be a
transparent change. Only for programs importing the latest rpc.proto it
will require code changes.

Signed-off-by: Adrian Reber <areber@redhat.com>
avagin pushed a commit that referenced this issue Apr 21, 2019
In rpc.proto the interface to query the CRIU version number uses major
and minor as keywords. This creates errors when using the RPC
definitions with C++: #625

In this commit the fields are renamed from major to major_number and
from minor to minor_number.

For existing programs using the RPC protobuf definition this should be a
transparent change. Only for programs importing the latest rpc.proto it
will require code changes.

Signed-off-by: Adrian Reber <areber@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants