pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inline functions with gnu99


From: John Darrington
Subject: Re: inline functions with gnu99
Date: Mon, 24 Mar 2008 10:32:40 +0900
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

OK.  See patch #6476 which fixes the problem for me.

Most of the inline functions turned out to be funcs whose address was
passed as interface members, so clearly inlining these was pointless.

There were a couple of functions of the form:

inline void thin_wrapper (int x)
{
  trivial_statement;
  other_function (x);
}

which I would have liked to leave inlined, but I can't be bothered to
fight GCC right now.

J'

On Sun, Mar 23, 2008 at 05:54:33PM -0700, Ben Pfaff wrote:
     John Darrington <address@hidden> writes:
     
     > Interesting.  I never knew there was more than one interpretation.
     >
     > To me, the inline keyword is a hint to the compiler that it might be
     > better to replace any calls to the function concerned with the body of
     > the function, rather than making a subroutine. 
     >
     > What else might it mean?
     
     That is always what "inline" means at the highest level.  But GCC
     and C99 "inline" have different linkage semantics.  Here is some
     information on the difference:
             http://gcc.gnu.org/ml/gcc/2006-11/msg00006.html
     
     Here is an excerpt from the GCC 4.3 manual, in the node titled
     "Inline", that talks about the static inline case:
     
          GCC implements three different semantics of declaring a function
         inline.  One is available with `-std=gnu89' or `-fgnu89-inline' or when
         `gnu_inline' attribute is present on all inline declarations, another
         when `-std=c99' or `-std=gnu99' (without `-fgnu89-inline'), and the
         third is used when compiling C++.
     
     [...]
     
          The three types of inlining behave similarly in two important cases:
         when the `inline' keyword is used on a `static' function, like the
         example above, and when a function is first declared without using the
         `inline' keyword and then is defined with `inline', like this:
     
              extern int inc (int *a);
              inline int
              inc (int *a)
              {
                (*a)++;
              }
     
          In both of these common cases, the program behaves the same as if you
         had not used the `inline' keyword, except for its speed.
     
     -- 
     Ben Pfaff 
     http://benpfaff.org
     
     
     _______________________________________________
     pspp-dev mailing list
     address@hidden
     http://lists.gnu.org/mailman/listinfo/pspp-dev

-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]