Opened 4 years ago

Closed 4 years ago

#222 closed defect (fixed)

gcc 4.3 semantic change of extern inline

Reported by: ydario Owned by: bird
Priority: normal Milestone: libc-0.6.4
Component: libc-frontend Version: 0.6.2
Severity: normal Keywords:
Cc:

Description

When compiling with -std=c99 or -std=gnu99, the extern inline keywords changes meaning. GCC 4.3 conforms to the ISO C99 specification, where extern inline is very different thing than the GNU extern inline extension.

If the old GNU extern inline behavior is desired, one can use extern inline attribute((gnu_inline)).

Only stdio.h have this problem.

Link: http://gcc.gnu.org/gcc-4.3/porting_to.html

Attachments (1)

stdio.diff (583 bytes) - added by komh 4 years ago.
patch for stdio.h

Download all attachments as: .zip

Change History (6)

comment:1 Changed 4 years ago by ydario

Current patch to stdio.h

--- stdio.h.orig	Sun Jun 10 15:44:44 2007
+++ stdio.h	Sat Aug 28 15:43:52 2010
@@ -526,18 +526,18 @@
 int _flush (int, FILE *);
 int _rmtmp (void);
 
-extern __inline__ int feof (FILE *_s)
+extern inline __attribute__((__gnu_inline__)) int feof (FILE *_s)
 {
   return (_s->_flags & _IOEOF ? 1 : 0);
 }
 
-extern __inline__ int ferror (FILE *_s)
+extern inline __attribute__((__gnu_inline__)) int ferror (FILE *_s)
 {
   return (_s->_flags & _IOERR ? 1 : 0);
 }
 
-extern __inline__ int getchar (void) { return getc (stdin); }
-extern __inline__ int putchar (int _c) { return putc (_c, stdout); }
+extern inline __attribute__((__gnu_inline__)) int getchar (void) { return getc (stdin); }
+extern inline __attribute__((__gnu_inline__)) int putchar (int _c) { return putc (_c, stdout); }
 
 #if !defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) || defined(__USE_EMX)
 

comment:2 Changed 4 years ago by bird

  • Component changed from gcc to libc-frontend
  • Status changed from new to assigned

The patch isn't quite right as we cannot use 'inline' in C headers, it must be 'inline'. The right thing to do here probably static inline func() {}'.

comment:3 Changed 4 years ago by ydario

I built a lot of code using above changes, from basic libs to full applications.

Changed 4 years ago by komh

patch for stdio.h

comment:4 Changed 4 years ago by komh

The above patch is the one being shipped with gcc4 in very first place.

See http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Inline.html#Inline

comment:5 Changed 4 years ago by bird

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [3714]) 0.6: Backported r3712 & r3713: stdio.h,features.h: Don't use gcc's 'extern inline' feature with 4.3.0 and later. Fixes #222.

Note: See TracTickets for help on using tickets.