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/21371] New: Missing timespec definition when compiled with _XOPEN_SOURCE and _POSIX_C_SOURCE


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

            Bug ID: 21371
           Summary: Missing timespec definition when compiled with
                    _XOPEN_SOURCE and _POSIX_C_SOURCE
           Product: glibc
           Version: 2.25
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: damien.riegel+sourceware at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

The following code snippet doesn't compile, but it does if time.h is included
first:

Code:
-----
#define _XOPEN_SOURCE 700
#define _POSIX_C_SOURCE 200112L

#include <sys/stat.h>
#include <time.h>

int main(int argc, char *argv[])
{
  struct timespec ts;

  return 0;
}


Error logs:
-----------
$ cc -c timespec_defined.c -o timespec_defined.o
In file included from /usr/include/sys/stat.h:101:0,
                 from timespec_defined.c:4:
/usr/include/bits/stat.h:91:21: error: field ‘st_atim’ has incomplete type
     struct timespec st_atim;  /* Time of last access.  */
                     ^~~~~~~
/usr/include/bits/stat.h:92:21: error: field ‘st_mtim’ has incomplete type
     struct timespec st_mtim;  /* Time of last modification.  */
                     ^~~~~~~
/usr/include/bits/stat.h:93:21: error: field ‘st_ctim’ has incomplete type
     struct timespec st_ctim;  /* Time of last status change.  */
                     ^~~~~~~
In file included from timespec_defined.c:4:0:
/usr/include/sys/stat.h:368:54: error: array type has incomplete element type
‘struct timespec’
 extern int futimens (int __fd, const struct timespec __times[2]) __THROW;



I am not sure if this _XOPEN_SOURCE/_POSIX_C_SOURCE combo makes sense or not,
this is the test case I ended up with when debugging a build failure in
Buildroot/uclibc and wanting to compare with glibc. Anyway, the fact that it
compiles when time.h is included first makes me believe that there is at least
something odd and worth investigating.

-- 
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]