ISO/ IEC JTC1/SC22/WG14 N741

                                            N741 J11/97-104
					    27 June 1997
					    Randy Meyers

Revised inline wording (Original Proposal was N709 Revision 1)

      Edits to draft C9X Draft 10 Keywords

 15   In the Syntax section, add to the list of keywords:  inline

      6.5 Declarations

      In the Syntax section, append to the  list  of  alternatives
      for the definition of declaration-specifiers:

 20   6.5.x Function-specifiers (a  new  subsection,  intended  to
      follow 6.5.3)


 25   Constraints

           Function-specifiers shall  be  used  only  in  function

|	   An inline definition (see below) of a function with external
|	   linkage shall not define an object of static storage duration
|	   or refer to an object with internal linkage.

|	   A file scope declaration without inline for a function with
|	   external linkage shall not follow a definition with inline
|	   of that function.


|	   The inline function specifier shall not appear in a
|	   declaration of main.

           A function declaration with an inline function  specif-
           ier  declares  an inline function.  Making a function an
|	   inline function suggests that calls to the function be as
|	   fast as possible (by, for example, using an alternative to
	   the usual function call mechanism known as ``inline
	   substitution''[footnote1]).  The extent to which such
|	   suggestions are effective is
|	   implementation-defined.[footnote2]

|	Footnote 1: Inline substitution is not textual substitution, nor
|	does it create a new function.  Therefore, for example, the
|	expansion of a macro used within the function uses the
|	definition it had at the point the function body appears, and
|	not where the function is called, and identifiers refer to the
|	declarations in scope where the body occurs.  Similarly, the
|	address of the function is not affected by the function being
|	inline.
|	Footnote 2: For example, an implementation might never perform
|	inline substitution, or might only perform inline substitutions
|	to calls in the scope of an inline declaration.
|	inline function specifier 

           Any function with internal linkage  can  be  an  inline
           function.   For  a  function with external linkage, the
           following  restrictions  apply.   If  a   function   is
  5        declared  with  an  inline  function specifier, then it
           shall also be defined in the same translation unit.  If
           all  of the file scope declarations for a function in a
           translation unit include the inline function specifier,
           then  the  definition  in  that  translation unit is an
 10        inline definition.  An inline definition does not  pro-
           vide  an  external definition of the function, and does
|          not forbid an external definition in another  translation
           unit.   An inline definition provides an alternative to
           an external definition, which a translator may  use  to
 15        implement any call to the function in the same transla-
|          tion unit.  It is unspecified whether a call to the
|	   function uses the inline definition or the external
|	   definition.

[Note by Meyers: the original proposal contained the following
instead of the above sentence:  The behavior of the program is
undefined if it depends upon whether the inline definition or the
external definition is used.]


 25        The declaration of an inline  function  can  result  in
           either  an  external definition, or a definition avail-
           able for use only within the translation unit.  A  file
           scope  declaration  without  inline creates an external
           definition.  The  following  example  shows  an  entire
 30        translation unit.

           extern double fahr(double); /* creates an external definition */

           inline double fahr(double t) {
              return (9.0 * t) / 5.0 + 32.0;

 35        inline double cels(double t) {
              return (5.0 * (t - 32.0)) / 9.0;

           double convert(int is_fahr, double temperature) {
              /* A translator may perform inline substitutions. */
 40           return is_fahr ? cels(temperature) : fahr(temperature);

           Note that the  declarations  of  inline  function  fahr
           result  in  the creation of an external definition, but
           the declaration of cels requires an external definition
           in another translation unit.