This is the mail archive of the libc-alpha@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]

Re: c99 and pthread.h


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


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