On Wed, 14 Jan 2015, Marek Polacek wrote: > A few months ago I posted the "porting to" document for GCC 5. > But I never got around to commit it, so here it is again, this > time with feewing.
Thanks again for doing this. Below is my last set of changes: Break some paragraphs and longer sentences, simplify/fix language, tweak markup and formatting. Applied. Gerald Index: porting_to.html =================================================================== RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-5/porting_to.html,v retrieving revision 1.9 diff -u -r1.9 porting_to.html --- porting_to.html 20 Apr 2015 00:29:07 -0000 1.9 +++ porting_to.html 20 Apr 2015 22:12:22 -0000 @@ -67,26 +67,28 @@ <h3>Default standard is now GNU11</h3> <p>GCC defaults to <code>-std=gnu11</code> instead of <code>-std=gnu89</code>. -This brings several changes that the users should be aware of. The following +This brings several changes that users should be aware of. The following paragraphs describe some of these changes and suggest how to deal with them. +</p> -Some users might prefer to stay with gnu89, in which case we suggest to use -the <code>-std=gnu89</code> command-line option, perhaps by putting it in -<code>override CFLAGS</code> or similarly in the Makefile.</p> +<p>Some users might prefer to stay with gnu89, in which case we suggest to +use the <code>-std=gnu89</code> command-line option, perhaps by putting it +in override <code>CFLAGS</code> or similarly in Makefiles.</p> <p>To ease the migration process, GCC offers two new warning options, <code>-Wc90-c99-compat</code> and <code>-Wc99-c11-compat</code>. The -former warns about features not present in ISO C90, but present in ISO C99 -and the latter warns about features not present in ISO C99, but present in +former warns about features not present in ISO C90, but present in ISO C99. +The latter warns about features not present in ISO C99, but present in ISO C11. See the GCC manual for more info.</p> <h4>Different semantics for inline functions</h4> + <p>While <code>-std=gnu89</code> employs the GNU89 inline semantics, <code>-std=gnu11</code> uses the C99 inline semantics. The C99 inline semantics requires that if a function with external linkage is declared with <code>inline</code> function specifier, it also has to be defined in the same -translation unit. Consequently, GCC now warns if it sees a TU such as the -following:</p> +translation unit (TU). Consequently, GCC now warns if it sees a TU +such as the following:</p> <pre><code> inline int foo (void); @@ -103,18 +105,20 @@ <p>Furthermore, there is a difference between <code>extern inline</code> and <code>inline</code>:</p> <ul> - <li>C99 <code>inline</code>: no externally visible function is generated; - if the function is referenced in this TU, external definition has to + <li>C99 <code>inline</code>: No externally visible function is generated. + If the function is referenced in this TU, an external definition has to exist in another TU; same as GNU89 <code>extern inline</code> with no - redefinition;</li> - <li>C99 <code>extern inline</code>: externally visible function is generated; - same as GNU89 <code>inline;</code></li> - <li>GNU89 <code>inline</code>: same as C99 <code>extern inline</code>;</li> - <li>GNU89 <code>extern inline</code>: no externally visible function is generated; - no equivalent in C99, because redefinition is not permitted.</li> + redefinition.</li> + <li>C99 <code>extern inline</code>: An externally visible function is + generated; same as GNU89 <code>inline</code>.</li> + <li>GNU89 <code>inline</code>: Same as C99 <code>extern inline</code>.</li> + <li>GNU89 <code>extern inline</code>: No externally visible function is + generated; no equivalent in C99, because redefinition is not + permitted.</li> </ul> (Fortunately <code>static inline</code> is the same in both C99 and GNU89.) + <p>In other words, ISO C99 requires that exactly one C source file has the callable copy of the inline function. Consider the following program:</p> @@ -132,8 +136,8 @@ } </code></pre> -<p>The program above will not link with the C99 inline semantics, because there -is not an out-of-line function <code>foo</code> generated. To fix this, either +<p>The program above will not link with the C99 inline semantics, because no +out-of-line function <code>foo</code> is generated. To fix this, either mark the function <code>foo</code> as <code>extern</code>, or add the following declaration:</p> @@ -239,7 +243,7 @@ <p>or use <code>-Wno-implicit</code> or <code>-Wno-implicit-int</code>.</p> <p>Another warning that is now turned on by default is the warning about -returning no value in function returning non-void:</p> +returning no value in a function returning non-void:</p> <pre><code> int @@ -258,7 +262,7 @@ </pre> <p>The fix is either to specify a proper return value, or to declare the return -value of <code>foo</code> as <code>void</code>.</p> +type of <code>foo</code> as <code>void</code>.</p> <h4>Initializing statics with compound literals</h4>