This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Problem with 'struct timespec' and C99 standard
- From: npak at ispras dot ru (Nickolay Pakoulin)
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 10 Feb 2004 15:23:41 +0300
- Subject: Problem with 'struct timespec' and C99 standard
Hello all!
I can not compile a program with 'struct timespec' when gcc is instructed to
follow C99 standard.
OS: RedHat 9 Cyrillic Edition
GCC: 3.2.2 and 3.3.2
Example: let's put the following lines in file t.c
#include <time.h>
struct timespec t;
Then compile it:
$ gcc -c t.c
Works fine.
$ gcc -std=c99 -c t.c
t.c:3: storage size of `t' isn't known
BUT:
$ gcc -std=gnu99 -c t.c
works!
I tried Intel compiler and it compiled successfully:
$icc -std=c99 -c t.c
struct timespec is defined in <time.h> as:
-------------------------------------------------------------------------------
#if !defined __timespec_defined && \
((defined _TIME_H && \
(defined __USE_POSIX199309 || defined __USE_MISC)) || \
defined __need_timespec)
# define __timespec_defined 1
/* POSIX.1b structure for a time value. This is like a `struct timeval' but
has nanoseconds instead of microseconds. */
struct timespec
{
__time_t tv_sec; /* Seconds. */
long int tv_nsec; /* Nanoseconds. */
};
#endif /* timespec not defined and <time.h> or need timespec. */
#undef __need_timespec
-------------------------------------------------------------------------------
The problem seems to be with __USE_POSIX199309: gcc does not define it when
-std=c99 is set. Is a gcc feature that when it follows C99 it ignores
POSIX.1b?
Nick.
PS: Please Cc: me , i am not subscribed to the list.