Uploaded image for project: 'Mesos'
  1. Mesos
  2. MESOS-8724

G++ Warning about libc system macros `major` and `minor` prevents Mesos build

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.5.2
    • Fix Version/s: 1.6.0
    • Component/s: None
    • Labels:
      None
    • Target Version/s:
    • Sprint:
      Mesosphere Sprint 78
    • Story Points:
      2

      Description

      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:

      ../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 {
      

      The root cause is that csi.proto defines the following protobuf message:

      message Version {
        uint32 major = 1;  // This field is REQUIRED.
        uint32 minor = 2;  // This field is REQUIRED.
        uint32 patch = 3;  // This field is REQUIRED.
      }
      

      The generated C++ in `csi.pb.h` headers will contain, amongst others, the following function:

      #include <string>
      
      // [6000 lines of code...]
      
      inline ::google::protobuf::uint32 Version::major() const {
        // @@protoc_insertion_point(field_get:csi.Version.major)
        return major_;
      }
      

      And the recursive include structure of the header `<string>` leads to `stdlib.h` as follows:

      .       /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
      ......  /usr/include/x86_64-linux-gnu/sys/types.h
      ....... /usr/include/x86_64-linux-gnu/sys/sysmacros.h

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                chhsia0 Chun-Hung Hsiao
                Reporter:
                bennoe Benno Evers
                Shepherd:
                Benjamin Bannier
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: