This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: c99 and pthread.h
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Ulrich Drepper <drepper at redhat dot com>
- Cc: Thorsten Kukuk <kukuk at suse dot de>, libc-alpha at sourceware dot org
- Date: Mon, 9 Jan 2006 22:19:43 +0100
- Subject: Re: c99 and pthread.h
- References: <20060109142452.GA22587@suse.de> <43C2C343.8030106@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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