Thread: inline function

  1. #1
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853

    inline function

    1) If understand correctly from tutorials in order to inline a function you add the inline keyword and nothing else. Is this correct? Is this the same for C89 and C99?
    2) Declaring inline a function from another file is done with the same way? There is a difference in C89 and C99 when using extern and inline, and thus an option in gcc to choose, but I can't understand the difference no matter how many times I read it. I feel kind of stupid

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Inline is only effective if the compiler can see the function when it's compiling the calling code.

    Also, inline is only a recommendation to the compiler that you think this function should be inlined, it does not guarantee that inline should be used. In gcc you can (sometimes) use -Winline to get information of why something isn't inlined.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    You seem to be correct but C89/C90 does not have inline. Only C99 does. You might be thinking of the GNU extensions labeled as GNU C89.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  5. Replies: 5
    Last Post: 02-08-2003, 07:42 PM