From b241411e502002395e4dcb2083bb3328dff66bd4 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 20 Oct 2014 23:26:58 +0000 Subject: Switch C compilations to C11 by default. This is long-since overdue, and matches GCC 5.0. This should also be backwards-compatible, because we already supported all of C11 as an extension in C99 mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220244 91177308-0d34-0410-b5e6-96231b3b80d8 --- www/compatibility.html | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'www') diff --git a/www/compatibility.html b/www/compatibility.html index 8bfaff191c..293be6f220 100644 --- a/www/compatibility.html +++ b/www/compatibility.html @@ -83,10 +83,10 @@

C99 inline functions

-

By default, Clang builds C code according to the C99 standard, -which provides different semantics for the inline keyword -than GCC's default behavior. For example, consider the following -code:

+

By default, Clang builds C code in GNU C11 mode, so it uses standard C99 +semantics for the inline keyword. These semantics are different +from those in GNU C89 mode, which is the default mode in versions of GCC +prior to 5.0. For example, consider the following code:

 inline int add(int i, int j) { return i + j; }
 
@@ -110,10 +110,10 @@ Undefined symbols:
       _main in cc-y1jXIr.o
 
-

By contrast, GCC's default behavior follows the GNU89 dialect, -which is the C89 standard plus a lot of extensions. C89 doesn't have -an inline keyword, but GCC recognizes it as an extension -and just treats it as a hint to the optimizer.

+

By contrast, GNU C89 mode (used by default in older versions of GCC) is the +C89 standard plus a lot of extensions. C89 doesn't have an inline +keyword, but GCC recognizes it as an extension and just treats it as a hint to +the optimizer.

There are several ways to fix this problem:

@@ -130,12 +130,12 @@ and just treats it as a hint to the optimizer.

for a function to be inlined, nor does it guarantee that it will be. Some compilers ignore it completely. Clang treats it as a mild suggestion from the programmer. - +
  • Provide an external (non-inline) definition of add somewhere else in your program. The two definitions must be equivalent!
  • -
  • Compile with the GNU89 dialect by adding +
  • Compile in the GNU C89 dialect by adding -std=gnu89 to the set of Clang options. This option is only recommended if the program source cannot be changed or if the program also relies on additional C89-specific behavior that cannot -- cgit v1.2.3