Benno Evers created MESOS-8724:
----------------------------------

             Summary: G++ Warning about libc system macros `major` and `minor` 
prevents Mesos build
                 Key: MESOS-8724
                 URL: https://issues.apache.org/jira/browse/MESOS-8724
             Project: Mesos
          Issue Type: Bug
            Reporter: Benno Evers


On linux systems, the header `<sys/sysmacros.h>` defines three macros called 
makedev(), major() and minor(). (See also 
http://man7.org/linux/man-pages/man3/makedev.3.html)

Trying to compile Mesos using g++ 7.2.0 leads to the following warning:
{noformat}
../include/csi/csi.pb.h:6042:13: error: In the GNU C Library, "minor" 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 "minor", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "minor", you should undefine it after including <sys/types.h>. [-Werror]
 inline ::google::protobuf::uint32 Version::minor() const {
{noformat}
The root cause is that csi.proto defines the following protobuf message:
{noformat}
message Version {
  uint32 major = 1;  // This field is REQUIRED.
  uint32 minor = 2;  // This field is REQUIRED.
  uint32 patch = 3;  // This field is REQUIRED.
}
{noformat}
The generated C++ in `csi.pb.h` headers will contain, amongst others, the 
following function:
{noformat}
#include <string>

// [6000 lines of code...]

inline ::google::protobuf::uint32 Version::major() const {
  // @@protoc_insertion_point(field_get:csi.Version.major)
  return major_;
}
{noformat}
And the recursive include structure of the header `<string>` leads to 
`stdlib.h` as follows:
{noformat}
.       /usr/include/c++/7/string
..      /usr/include/c++/7/bits/basic_string.h
...     /usr/include/c++/7/ext/string_conversions.h
....    /usr/include/c++/7/cstdlib
.....   /usr/include/stdlib.h{noformat}
 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to