This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/19239] New: Including stdlib.h ends up with macros major and minor being defined


https://sourceware.org/bugzilla/show_bug.cgi?id=19239

            Bug ID: 19239
           Summary: Including stdlib.h ends up with macros major and minor
                    being defined
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: yaghmour.shafik at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

Given the following code:

#include <fstream> //or iostream, sstream, istream, ostream

struct A {
  unsigned major;
  unsigned minor;

  A(int major, int minor) :
    major(major), minor(minor){ }
};

int main() {
  A a1(1, 1);

  return 0;
}

which is a reduced example from this Stackoverflow queston:
http://stackoverflow.com/q/33681093/1708801

Generates the following diagnostics
http://melpon.org/wandbox/permlink/Bex1ymr03yuu44Pd:

prog.cc:8:5: error: member initializer 'gnu_dev_major' does not name a
non-static data member or base class
    major(major), minor(minor){ }
    ^~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:67:21: note: expanded from macro
'major'
# define major(dev) gnu_dev_major (dev)
                    ^~~~~~~~~~~~~~~~~~~
prog.cc:8:19: error: member initializer 'gnu_dev_minor' does not name a
non-static data member or base class
    major(major), minor(minor){ }
                  ^~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:68:21: note: expanded from macro
'minor'
# define minor(dev) gnu_dev_minor (dev)
                    ^~~~~~~~~~~~~~~~~~~
2 errors generated.

So it looks like the underlying issue is that various stream related headers
bring in stdlib.h which eventually casues sys/sysmacros.h to be be included.
The details were identified in one of the comments which said:

_GNU_SOURCE causes stdlib.h to include sys/types.h, and it causes sys/types.h
to include sys/sysmacros.h

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]