summaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/cpp.texi22
-rw-r--r--gcc/doc/extend.texi42
-rw-r--r--gcc/doc/invoke.texi24
3 files changed, 81 insertions, 7 deletions
diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index 39bafe6becd..f0e2bb9d78f 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -2014,6 +2014,28 @@ functions. You should not use these macros in any way unless you make
sure that programs will execute with the same effect whether or not they
are defined. If they are defined, their value is 1.
+@item __GNUC_GNU_INLINE__
+GCC defines this macro if functions declared @code{inline} will be
+handled in GCC's traditional gnu89 mode. In this mode an @code{extern
+inline} function will never be compiled as a standalone function, and
+an @code{inline} function which is neither @code{extern} nor
+@code{static} will always be compiled as a standalone function.
+
+@item __GNUC_STDC_INLINE__
+GCC defines this macro if functions declared @code{inline} will be
+handled according to the ISO C99 standard. In this mode an
+@code{extern inline} function will always be compiled as a standalone
+externally visible function, and an @code{inline} function which is
+neither @code{extern} nor @code{static} will never be compiled as a
+standalone function.
+
+If this macro is defined, GCC supports the @code{gnu_inline} function
+attribute as a way to always get the gnu89 behaviour. Support for
+this and @code{__GNUC_GNU_INLINE__} was added in GCC 4.1.3. If
+neither macro is defined, an older version of GCC is being used:
+@code{inline} functions will be compiled in gnu89 mode, and the
+@code{gnu_inline} function attribute will not be recognized.
+
@item __CHAR_UNSIGNED__
GCC defines this macro if and only if the data type @code{char} is
unsigned on the target machine. It exists to cause the standard header
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index ad3404a0b3d..dfa4f5d4aa3 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1618,8 +1618,37 @@ if no optimization level was specified.
@item gnu_inline
@cindex @code{gnu_inline} function attribute
-This attribute on an inline declaration results in the old GNU C89
-inline behavior even in the ISO C99 mode.
+This attribute should be used with a function which is also declared
+with the @code{inline} keyword. It directs GCC to treat the function
+as if it were defined in gnu89 mode even when compiling in C99 or
+gnu99 mode.
+
+If the function is declared @code{extern}, then this definition of the
+function is used only for inlining. In no case is the function
+compiled as a standalone function, not even if you take its address
+explicitly. Such an address becomes an external reference, as if you
+had only declared the function, and had not defined it. This has
+almost the effect of a macro. The way to use this is to put a
+function definition in a header file with this attribute, and put
+another copy of the function, without @code{extern}, in a library
+file. The definition in the header file will cause most calls to the
+function to be inlined. If any uses of the function remain, they will
+refer to the single copy in the library. Note that the two
+definitions of the functions need not be precisely the same, although
+if they do not have the same effect your program may behave oddly.
+
+If the function is neither @code{extern} nor @code{static}, then the
+function is compiled as a standalone function, as well as being
+inlined where possible.
+
+This is how GCC traditionally handled functions declared
+@code{inline}. Since ISO C99 specifies a different semantics for
+@code{inline}, this function attribute is provided as a transition
+measure and as a useful feature in its own right. This attribute is
+available in GCC 4.1.3 and later. It is available if either of the
+preprocessor macros @code{__GNUC_GNU_INLINE__} or
+@code{__GNUC_STDC_INLINE__} are defined. @xref{Inline,,An Inline
+Function is As Fast As a Macro}.
@cindex @code{flatten} function attribute
@item flatten
@@ -3846,10 +3875,11 @@ also direct GCC to try to integrate all ``simple enough'' functions
into their callers with the option @option{-finline-functions}.
GCC implements three different semantics of declaring a function
-inline. One is available with @option{-std=gnu89} or when @code{gnu_inline}
-attribute is present on all inline declarations, another when
-@option{-std=c99} or @option{-std=gnu99}, and the third is used when
-compiling C++.
+inline. One is available with @option{-std=gnu89} or
+@option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
+on all inline declarations, another when @option{-std=c99} or
+@option{-std=gnu99} (without @option{-fgnu89-inline}), and the third
+is used when compiling C++.
To declare a function inline, use the @code{inline} keyword in its
declaration, like this:
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index ccd6a54dd92..85416349542 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -166,7 +166,8 @@ in the following sections.
@item C Language Options
@xref{C Dialect Options,,Options Controlling C Dialect}.
-@gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} @gol
+@gccoptlist{-ansi -std=@var{standard} -fgnu89-inline @gol
+-aux-info @var{filename} @gol
-fno-asm -fno-builtin -fno-builtin-@var{function} @gol
-fhosted -ffreestanding -fopenmp -fms-extensions @gol
-trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol
@@ -1351,6 +1352,27 @@ the @code{inline} keyword in ISO C99) are not disabled.
@xref{Standards,,Language Standards Supported by GCC}, for details of
these standard versions.
+@item -fgnu89-inline
+@opindex fgnu89-inline
+The option @option{-fgnu89-inline} tells GCC to use the traditional
+GNU semantics for @code{inline} functions when in C99 mode.
+@xref{Inline,,An Inline Function is As Fast As a Macro}. This option
+is accepted and ignored by GCC versions 4.1.3 up to but not including
+4.3. In GCC versions 4.3 and later it changes the behavior of GCC in
+C99 mode. Using this option is roughly equivalent to adding the
+@code{gnu_inline} function attribute to all inline functions
+(@pxref{Function Attributes}).
+
+The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
+C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
+specifies the default behavior). This option was first supported in
+GCC 4.3. This option is not supported in C89 or gnu89 mode.
+
+The preprocesor macros @code{__GNUC_GNU_INLINE__} and
+@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
+in effect for @code{inline} functions. @xref{Common Predefined
+Macros,,,cpp.info,The C Preprocessor}.
+
@item -aux-info @var{filename}
@opindex aux-info
Output to the given filename prototyped declarations for all functions