c99 and pthread.h
Jakub Jelinek
jakub@redhat.com
Mon Jan 9 21:19:00 GMT 2006
On Mon, Jan 09, 2006 at 12:10:43PM -0800, Ulrich Drepper wrote:
> Thorsten Kukuk wrote:
> > with current glibc CVS I get an error message if I use pthread.h,
> > mutex initializer and compile with -std=c99:
>
> gcc ignores the transparent union in c99 mode. This does not look
> right. You might want to ask the gcc people instead.
But anonymous unions aren't ISO C99 nor ISO C89, which is why GCC complains.
I have tested __extension__ shuts this up, but that lefts out non-GCC
compilers. So we can use:
__extension__ union
{
int __spins;
struct __pthread_mutex_s *__next;
};
if we don't care about non-GCC (verified this shuts the errors/warnings
up in both -std=c89 and -std=c99 mode), or e.g.
__extension__ union
{
int __spins;
struct __pthread_mutex_s *__next;
}
# if __GNUC_PREREQ (3,2)
;
# else
s;
# endif
(3.2 chosen arbitrarily, would need to see when exactly was anonymous
union support added), or
__extension__ union
{
int __spins;
struct __pthread_mutex_s *__next;
}
# ifdef _LIBC
;
# else
s;
# endif
Jakub
More information about the Libc-alpha
mailing list