Re: inline

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: tom_usenet (tom_usenet_at_hotmail.com)
Date: 05/21/04


Date: Fri, 21 May 2004 13:44:03 +0100

On Fri, 21 May 2004 13:13:35 +0200, "Miki Peric" <blah@ccc.com> wrote:

>
>I have function defined as inline in header file. Function belongs to a
>class (class member). When linking as static lib, function is not linked
>into lib. When I include this lib into my project I got an unresolved linker
>error. Linker can't find function. What should I do?

I can't replicate your problem - linking isn't (or shouldn't be) an
issue for inline functions generally - they don't need to be linked
into the static library, since their definition is inserted directly
where used in general. An exception is when you take the address of
the function. Static local variables also require a bit more
compiler/linker jiggorypokery, so details of whether your inline
function contains any would be useful.

It would be helpful if you gave details of your source code
organization - all files that reference your inline function in any
way. e.g.

Library:

staticlib.h:
Class definition + inline function definition of "foo"
"foo" includes a static local variable.
staticlib.cpp:
#include "staticlib.h"
Non-inline definitions
staticlib2.cpp:
#include "staticlib.h"
Takes address of "foo"

Exe:

exe.cpp:
#include "staticlib.h"
uses "foo"

Or whatever.

Tom

-- 
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html


Relevant Pages

  • Re: linker errors builing a non unicode project using CComPtr
    ... filters without this lib? ... You can omit the baseclasses lib if you don't have anything that requires ... Trim & respond inline (please don't top post or snip everything) ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: inline function call
    ... > Can I call a function in python inline, so that the python byte compiler ... called with a and b of int type, then a special version of foo is compiled ...
    (comp.lang.python)
  • Re: inline function call
    ... >> Can I call a function in python inline, so that the python byte compiler ... Inlining is putting code to accomplish what foo does in place of the foo call. ... This could be achieved by a custom import function that would capture the AST ... of foo and bar, and extracting that from the AST and modifying the rest of the ...
    (comp.lang.python)
  • Re: calloc.... Why?
    ... >> And using references doesn't make the optimizer's job any ... >and registers), but when the function's inline, the stack ... The compiler can choose to inline ... int foo = 10; ...
    (comp.lang.cpp)
  • Re: Automatically stylizing function/variable names?
    ... foo three ... bar four ... However, he's made it fairly clear that this is not what he wants, because it requires commands in the inline text. ...
    (comp.text.tex)