Inline functions...

This is a discussion on Inline functions... within the C++ Programming forums, part of the General Programming Boards category; What are the advantages/disadvantages of using inline functions? I know what they are, but I don't know the benefits/costs of ...

  1. #1
    ER
    Guest

    Inline functions...

    What are the advantages/disadvantages of using inline functions? I know what they are, but I don't know the benefits/costs of using them. I see them almost everywhere in code, but if they were entirely beneficial, they would be part of every function. So, what gives?

  2. #2
    Registered User kitten's Avatar
    Join Date
    Aug 2001
    Posts
    109
    Inline functions should be written in header files. Usually every function is in its own "code region" and when the function is called its parameters are put into the stack and program's execution jumps to that address where the function begins. In inline function's case the code won't be generated to any certain location but to that point where the inline function is called. So if you call an inline function multiple times you have its code multiple times in your executable.

    So inline functions are usually very short functions that are called often (maybe >100000 times / sec). The benefit is that the execution doesn't need to jump to other location, which can be a time-saving if executed 100000 times / sec. Disadvantage is the code bloat caused by many inline function calls in your code, especially when the inline function is long. So they can increase the size of your executable tremendously.
    Making error is human, but for messing things thoroughly it takes a computer

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inline Definitions and Declarations?
    By legit in forum C++ Programming
    Replies: 1
    Last Post: 06-15-2009, 02:59 PM
  2. Is it legal to have functions within functions?
    By Programmer_P in forum C++ Programming
    Replies: 13
    Last Post: 05-26-2009, 12:21 AM
  3. When to inline your *tors
    By Angus in forum C++ Programming
    Replies: 43
    Last Post: 10-29-2008, 04:38 PM
  4. conditional breakpoints and inline functions
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 08-10-2006, 09:30 PM
  5. inline friend functions.
    By sean in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2002, 12:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21