Mercurial > hg > octave-lojdl > gnulib-hg
annotate m4/extern-inline.m4 @ 17436:54c2b89ac5ec
extern-inline: port to gcc -std=c89
* m4/extern-inline.m4 (gl_EXTERN_INLINE):
Do not use __gnu_inline__ if pedantic and pre-C99.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 21 Jun 2013 12:33:40 -0700 |
parents | a0d0b52b7d06 |
children |
rev | line source |
---|---|
17022 | 1 dnl 'extern inline' a la ISO C99. |
2 | |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
17205
diff
changeset
|
3 dnl Copyright 2012-2013 Free Software Foundation, Inc. |
17022 | 4 dnl This file is free software; the Free Software Foundation |
5 dnl gives unlimited permission to copy and/or distribute it, | |
6 dnl with or without modifications, as long as this notice is preserved. | |
7 | |
8 AC_DEFUN([gl_EXTERN_INLINE], | |
9 [ | |
10 AH_VERBATIM([extern_inline], | |
17435
a0d0b52b7d06
doc: document extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
17383
diff
changeset
|
11 [/* Please see the Gnulib manual for how to use these macros. |
17205
80b56d8fd2b7
extern-inline: avoid incompatibility with Darwin Libc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17195
diff
changeset
|
12 |
17338
6f8d1926ece8
extern-inline: avoid compilation error with HP-UX cc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
13 Suppress extern inline with HP-UX cc, as it appears to be broken; see |
6f8d1926ece8
extern-inline: avoid compilation error with HP-UX cc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
14 <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>. |
6f8d1926ece8
extern-inline: avoid compilation error with HP-UX cc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
15 |
17383
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
16 Suppress extern inline with Sun C in standards-conformance mode, as it |
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
17 mishandles inline functions that call each other. E.g., for 'inline void f |
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
18 (void) { } inline void g (void) { f (); }', c99 incorrectly complains |
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
19 'reference to static identifier "f" in extern inline function'. |
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
20 This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. |
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
21 |
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
22 Suppress the use of extern inline on Apple's platforms, as Libc at least |
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
23 through Libc-825.26 (2013-04-09) is incompatible with it; see, e.g., |
17205
80b56d8fd2b7
extern-inline: avoid incompatibility with Darwin Libc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17195
diff
changeset
|
24 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. |
80b56d8fd2b7
extern-inline: avoid incompatibility with Darwin Libc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17195
diff
changeset
|
25 Perhaps Apple will fix this some day. */ |
80b56d8fd2b7
extern-inline: avoid incompatibility with Darwin Libc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17195
diff
changeset
|
26 #if ((__GNUC__ \ |
80b56d8fd2b7
extern-inline: avoid incompatibility with Darwin Libc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17195
diff
changeset
|
27 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ |
17383
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
28 : (199901L <= __STDC_VERSION__ \ |
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
29 && !defined __HP_cc \ |
f9ba1e745bd9
extern-inline: work around bug in Sun c99
Paul Eggert <eggert@cs.ucla.edu>
parents:
17338
diff
changeset
|
30 && !(defined __SUNPRO_C && __STDC__))) \ |
17205
80b56d8fd2b7
extern-inline: avoid incompatibility with Darwin Libc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17195
diff
changeset
|
31 && !defined __APPLE__) |
17022 | 32 # define _GL_INLINE inline |
33 # define _GL_EXTERN_INLINE extern inline | |
17436
54c2b89ac5ec
extern-inline: port to gcc -std=c89
Paul Eggert <eggert@cs.ucla.edu>
parents:
17435
diff
changeset
|
34 #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ |
54c2b89ac5ec
extern-inline: port to gcc -std=c89
Paul Eggert <eggert@cs.ucla.edu>
parents:
17435
diff
changeset
|
35 && !defined __APPLE__) |
17056
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
36 # if __GNUC_GNU_INLINE__ |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
37 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
38 # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
39 # else |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
40 # define _GL_INLINE extern inline |
17022 | 41 # endif |
17056
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
42 # define _GL_EXTERN_INLINE extern |
17022 | 43 #else |
17205
80b56d8fd2b7
extern-inline: avoid incompatibility with Darwin Libc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17195
diff
changeset
|
44 # define _GL_INLINE static _GL_UNUSED |
80b56d8fd2b7
extern-inline: avoid incompatibility with Darwin Libc
Paul Eggert <eggert@cs.ucla.edu>
parents:
17195
diff
changeset
|
45 # define _GL_EXTERN_INLINE static _GL_UNUSED |
17022 | 46 #endif |
47 | |
17056
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
48 #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) |
17112
03d96692c889
extern-inline: provide a -Wundef safe config.h
Akim Demaille <akim@lrde.epita.fr>
parents:
17056
diff
changeset
|
49 # if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ |
17056
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
50 # define _GL_INLINE_HEADER_CONST_PRAGMA |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
51 # else |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
52 # define _GL_INLINE_HEADER_CONST_PRAGMA \ |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
53 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
54 # endif |
17435
a0d0b52b7d06
doc: document extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
17383
diff
changeset
|
55 /* Suppress GCC's bogus "no previous prototype for 'FOO'" |
a0d0b52b7d06
doc: document extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
17383
diff
changeset
|
56 and "no previous declaration for 'FOO'" diagnostics, |
a0d0b52b7d06
doc: document extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
17383
diff
changeset
|
57 when FOO is an inline function in the header; see |
a0d0b52b7d06
doc: document extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents:
17383
diff
changeset
|
58 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */ |
17056
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
59 # define _GL_INLINE_HEADER_BEGIN \ |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
60 _Pragma ("GCC diagnostic push") \ |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
61 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
62 _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \ |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
63 _GL_INLINE_HEADER_CONST_PRAGMA |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
64 # define _GL_INLINE_HEADER_END \ |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
65 _Pragma ("GCC diagnostic pop") |
373b50f0c218
extern-inline: support old GCC 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
17035
diff
changeset
|
66 #else |
17022 | 67 # define _GL_INLINE_HEADER_BEGIN |
68 # define _GL_INLINE_HEADER_END | |
69 #endif]) | |
70 ]) |