inline functions

Discussion in 'C++' started by sunil, Aug 26, 2008.

  1. sunil

    sunil Guest

    Hello,
    Does member function inlining in C++ guarantee that multiple files
    including a header (that includes implementation for function member
    thats inlined) wont get multiply defined linker errors even if
    compiler decides NOT to inline the function?
    I experimented this in a sunOS machine forcing compiler not to inline
    a function, and the scope of functions is LOCL (i.e. its not visible
    to other modules) and so I dont get linktime errors . Does C++
    standard define this as behavior?
    Thanks
    sunil, Aug 26, 2008
    #1
    1. Advertising

  2. sunil

    Bo Persson Guest

    sunil wrote:
    > Hello,
    > Does member function inlining in C++ guarantee that multiple files
    > including a header (that includes implementation for function member
    > thats inlined) wont get multiply defined linker errors even if
    > compiler decides NOT to inline the function?
    > I experimented this in a sunOS machine forcing compiler not to
    > inline a function, and the scope of functions is LOCL (i.e. its not
    > visible to other modules) and so I dont get linktime errors . Does
    > C++ standard define this as behavior?
    > Thanks


    Yes, it does.


    Bo Persson
    Bo Persson, Aug 26, 2008
    #2
    1. Advertising

  3. sunil wrote:
    > Does member function inlining in C++ guarantee that multiple files
    > including a header (that includes implementation for function member
    > thats inlined) wont get multiply defined linker errors even if
    > compiler decides NOT to inline the function?


    Think about it the other way around: Would it make any sense if inline
    functions would be treated as regular functions, causing linker errors?
    That would make inline functions rather useless, and not only useless,
    but something to avoid like a plague. The whole concept would have no
    reason to exist.
    Juha Nieminen, Aug 26, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abhi
    Replies:
    2
    Views:
    734
    E. Robert Tisdale
    Jul 3, 2003
  2. Replies:
    3
    Views:
    457
  3. Daniel Vallstrom
    Replies:
    2
    Views:
    1,872
    Kevin Bracey
    Nov 21, 2003
  4. jamihuq

    converting inline functions to C functions

    jamihuq, May 16, 2006, in forum: C Programming
    Replies:
    7
    Views:
    344
  5. Rahul
    Replies:
    3
    Views:
    453
    James Kanze
    Feb 28, 2008
Loading...

Share This Page