bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extern inline problem with argp when building tar 1.19 with GCC 4.2.


From: Bruno Haible
Subject: Re: extern inline problem with argp when building tar 1.19 with GCC 4.2.1
Date: Sat, 13 Oct 2007 15:26:47 +0200
User-agent: KMail/1.5.4

Hi Paul,

> 2007-10-12  Paul Eggert  <address@hidden>
> 
>       * lib/argp-fmtstream.h (ARGP_FS_EI): Work around GCC 4.2.1 diagnostic
>       "warning: C99 inline functions are not supported; using GNU89".

This does not fix all warnings. I still get these warnings (on SuSE Linux 9.0,
gcc 4.2.1):

gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I..     -g -O2 -MT argp-eexst.o -MD -MP -MF 
.deps/argp-eexst.Tpo -c -o argp-eexst.o argp-eexst.c
In file included from argp-eexst.c:25:
argp.h:587: Warnung: C99 inline functions are not supported; using GNU89
argp.h:587: Warnung: to disable this warning use -fgnu89-inline or the 
gnu_inline function attribute
argp.h:593: Warnung: C99 inline functions are not supported; using GNU89
argp.h:605: Warnung: C99 inline functions are not supported; using GNU89
mv -f .deps/argp-eexst.Tpo .deps/argp-eexst.Po

Adding a similar definition for ARGP_EI fixes these warning.

But, more importantly, the purpose of the GCC 4.2.1 warnings is to make
people aware that there is a portability problem to GCC >= 4.3.0, because
'inline' in GCC 4.3.0 -std=gnu99 has a different meaning. Silencing the
warning without caring about what happens with gcc 4.3.0 is not good.

With a gcc 4.3.0 snapshot in a testdir for the argp module:

$ ./configure CC="gcc -std=gnu99" CPPFLAGS=-Wall
$ make
...
Making all in gltests
make[2]: Entering directory `/dev/shm/testdir1/gltests'
make  all-recursive
make[3]: Entering directory `/dev/shm/testdir1/gltests'
make[4]: Entering directory `/dev/shm/testdir1/gltests'
gcc -std=gnu99  -g -O2   -o test-argp test-argp.o ../gllib/libgnu.a  
../gllib/libgnu.a(argp-fmtstream.o): In function `argp_fmtstream_putc':
/dev/shm/testdir1/gllib/argp-fmtstream.h:238: multiple definition of 
`argp_fmtstream_putc'
../gllib/libgnu.a(argp-help.o):/dev/shm/testdir1/gllib/argp-fmtstream.h:238: 
first defined here
../gllib/libgnu.a(argp-fmtstream.o): In function `argp_fmtstream_point':
/dev/shm/testdir1/gllib/argp-fmtstream.h:284: multiple definition of 
`argp_fmtstream_point'
../gllib/libgnu.a(argp-help.o):/dev/shm/testdir1/gllib/argp-fmtstream.h:284: 
first defined here
../gllib/libgnu.a(argp-fmtstream.o): In function `argp_fmtstream_set_wmargin':
/dev/shm/testdir1/gllib/argp-fmtstream.h:272: multiple definition of 
`argp_fmtstream_set_wmargin'
../gllib/libgnu.a(argp-help.o):/dev/shm/testdir1/gllib/argp-fmtstream.h:272: 
first defined here
../gllib/libgnu.a(argp-fmtstream.o): In function `argp_fmtstream_set_rmargin':
/dev/shm/testdir1/gllib/argp-fmtstream.h:260: multiple definition of 
`argp_fmtstream_set_rmargin'
../gllib/libgnu.a(argp-help.o):/dev/shm/testdir1/gllib/argp-fmtstream.h:260: 
first defined here
../gllib/libgnu.a(argp-fmtstream.o): In function `argp_fmtstream_set_lmargin':
/dev/shm/testdir1/gllib/argp-fmtstream.h:248: multiple definition of 
`argp_fmtstream_set_lmargin'
../gllib/libgnu.a(argp-help.o):/dev/shm/testdir1/gllib/argp-fmtstream.h:248: 
first defined here
../gllib/libgnu.a(argp-fmtstream.o): In function `argp_fmtstream_write':
/dev/shm/testdir1/gllib/argp-fmtstream.h:212: multiple definition of 
`argp_fmtstream_write'
../gllib/libgnu.a(argp-help.o):/dev/shm/testdir1/gllib/argp-fmtstream.h:212: 
first defined here
../gllib/libgnu.a(argp-fmtstream.o): In function `argp_fmtstream_puts':
/dev/shm/testdir1/gllib/argp-fmtstream.h:225: multiple definition of 
`argp_fmtstream_puts'
../gllib/libgnu.a(argp-help.o):/dev/shm/testdir1/gllib/argp-fmtstream.h:225: 
first defined here
collect2: ld returned 1 exit status
make[4]: *** [test-argp] Error 1
make[4]: Leaving directory `/dev/shm/testdir1/gltests'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/dev/shm/testdir1/gltests'
make[2]: *** [all] Error 2

I'm applying the appended change, that fixes it.

References:
[1] http://lists.gnu.org/archive/html/bug-gnulib/2006-11/msg00055.html
[2] http://lists.gnu.org/archive/html/bug-gnu-utils/2007-09/msg00032.html


2007-10-13  Bruno Haible  <address@hidden>

        Handle 'inline' change in gcc 4.3.0.
        * lib/argp-fmtstream.h (argp_fmtstream_putc, argp_fmtstream_puts,
        argp_fmtstream_write, argp_fmtstream_set_lmargin,
        argp_fmtstream_set_rmargin, argp_fmtstream_set_wmargin,
        argp_fmtstream_point): Disable 'extern' declaration if the function
        definition is going to be provided inline.
        (ARGP_FS_EI): If __GNUC_STDC_INLINE__ is defined, use the GNU C inline
        semantics, not the ISO C99 inline semantics.
        * lib/argp.h (argp_usage, _option_is_short, _option_is_end): Disable
        'extern' declaration if the function definition is going to be provided
        inline.
        (ARGP_EI): Don't assume GNU C. If __GNUC_STDC_INLINE__ is defined, use
        the GNU C inline semantics, not the ISO C99 inline semantics. With
        GCC 4.2, avoid a warning.

*** lib/argp-fmtstream.h.orig   2007-10-13 15:18:42.000000000 +0200
--- lib/argp-fmtstream.h        2007-10-13 15:18:32.000000000 +0200
***************
*** 1,5 ****
  /* Word-wrapping and line-truncating streams.
!    Copyright (C) 1997, 2006 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
     Written by Miles Bader <address@hidden>.
  
--- 1,5 ----
  /* Word-wrapping and line-truncating streams.
!    Copyright (C) 1997, 2006-2007 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
     Written by Miles Bader <address@hidden>.
  
***************
*** 134,139 ****
--- 134,140 ----
                                      const char *__fmt, ...)
       __attribute__ ((__format__ (printf, 2, 3)));
  
+ #if _LIBC || !defined __OPTIMIZE__
  extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
  extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
  
***************
*** 144,149 ****
--- 145,151 ----
                                      const char *__str, size_t __len);
  extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
                                    const char *__str, size_t __len);
+ #endif
   
  /* Access macros for various bits of state.  */
  #define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin)
***************
*** 153,158 ****
--- 155,161 ----
  #define __argp_fmtstream_rmargin argp_fmtstream_rmargin
  #define __argp_fmtstream_wmargin argp_fmtstream_wmargin
  
+ #if _LIBC || !defined __OPTIMIZE__
  /* Set __FS's left margin to LMARGIN and return the old value.  */
  extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
                                          size_t __lmargin);
***************
*** 174,179 ****
--- 177,183 ----
  /* Return the column number of the current output point in __FS.  */
  extern size_t argp_fmtstream_point (argp_fmtstream_t __fs);
  extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs);
+ #endif
  
  /* Internal routines.  */
  extern void _argp_fmtstream_update (argp_fmtstream_t __fs);
***************
*** 197,207 ****
  #endif
  
  #ifndef ARGP_FS_EI
! # if __GNUC_GNU_INLINE__
! #  define ARGP_FS_EI extern inline __attribute__ ((__gnu_inline__))
! # elif __GNUC__
! #  define ARGP_FS_EI extern inline
  # else
  #  define ARGP_FS_EI inline
  # endif
  #endif
--- 201,224 ----
  #endif
  
  #ifndef ARGP_FS_EI
! # ifdef __GNUC__
!    /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
!       inline semantics, unless -fgnu89-inline is used.  It defines a macro
!       __GNUC_STDC_INLINE__ to indicate this situation or a macro
!       __GNUC_GNU_INLINE__ to indicate the opposite situation.
!       GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
!       semantics but warns, unless -fgnu89-inline is used:
!         warning: C99 inline functions are not supported; using GNU89
!         warning: to disable this warning use -fgnu89-inline or the gnu_inline 
function attribute
!       It defines a macro __GNUC_GNU_INLINE__ to indicate this situation.  */
! #  if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
! #   define ARGP_FS_EI extern inline __attribute__ ((__gnu_inline__))
! #  else
! #   define ARGP_FS_EI extern inline
! #  endif
  # else
+    /* With other compilers, assume the ISO C99 meaning of 'inline', if
+       the compiler supports 'inline' at all.  */
  #  define ARGP_FS_EI inline
  # endif
  #endif
*** lib/argp.h.orig     2007-10-13 15:18:42.000000000 +0200
--- lib/argp.h  2007-10-13 14:58:37.000000000 +0200
***************
*** 520,528 ****
--- 520,530 ----
                               FILE *__restrict __stream,
                               unsigned int __flags);
  
+ #if _LIBC || !defined __USE_EXTERN_INLINES
  /* Possibly output the standard usage message for ARGP to stderr and exit.  */
  extern void argp_usage (const struct argp_state *__state);
  extern void __argp_usage (const struct argp_state *__state);
+ #endif
  
  /* If appropriate, print the printf string FMT and following args, preceded
     by the program name and `:', to stderr, and followed by a `Try ... --help'
***************
*** 551,556 ****
--- 553,559 ----
                            const char *__restrict __fmt, ...)
       __attribute__ ((__format__ (__printf__, 4, 5)));
  
+ #if _LIBC || !defined __USE_EXTERN_INLINES
  /* Returns true if the option OPT is a valid short option.  */
  extern int _option_is_short (const struct argp_option *__opt) __THROW;
  extern int __option_is_short (const struct argp_option *__opt) __THROW;
***************
*** 559,564 ****
--- 562,568 ----
     options array.  */
  extern int _option_is_end (const struct argp_option *__opt) __THROW;
  extern int __option_is_end (const struct argp_option *__opt) __THROW;
+ #endif
  
  /* Return the input field for ARGP in the parser corresponding to STATE; used
     by the help routines.  */
***************
*** 579,585 ****
  # endif
  
  # ifndef ARGP_EI
! #  define ARGP_EI extern __inline__
  # endif
  
  ARGP_EI void
--- 583,608 ----
  # endif
  
  # ifndef ARGP_EI
! #  ifdef __GNUC__
!     /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
!        inline semantics, unless -fgnu89-inline is used.  It defines a macro
!        __GNUC_STDC_INLINE__ to indicate this situation or a macro
!        __GNUC_GNU_INLINE__ to indicate the opposite situation.
!        GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
!        semantics but warns, unless -fgnu89-inline is used:
!          warning: C99 inline functions are not supported; using GNU89
!          warning: to disable this warning use -fgnu89-inline or the 
gnu_inline function attribute
!        It defines a macro __GNUC_GNU_INLINE__ to indicate this situation.  */
! #   if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
! #    define ARGP_EI extern __inline__ __attribute__ ((__gnu_inline__))
! #   else
! #    define ARGP_EI extern __inline__
! #   endif
! #  else
!     /* With other compilers, assume the ISO C99 meaning of 'inline', if
!        the compiler supports 'inline' at all.  */
! #   define ARGP_EI inline
! #  endif
  # endif
  
  ARGP_EI void





reply via email to

[Prev in Thread] Current Thread [Next in Thread]