Re: undefined reference to... when calling an inline function in a shared library

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

 



Hi Lennyk,

> What am I doing wrong?

You are specifying 'inline' for Foo::Nothing.

Since you want Foo::Nothing to live in libfoo.so, you do not want it to be
inline.

OTHERWISE...

> How can I expose an inline function WITHOUT implementing it in the
> header file?

You can't.

You need to make inline Foo::Nothing visible to the code that will be
inlining it.

At the bottom of foo.h, add:
#include "foo.inline.h"

Rename foo.cpp to foo.inline.h .

Remove the #include "foo.h" from foo.inline.h .

Technically, it is in a header file.  But it is a special header file:  an
implementation header file for inline routines.

Some people use "foo.ipp" as the extension.

Similiarly, for template implementations I've seen "foo.tpp", which is
#include "foo.tpp" at the bottom of the "foo.h" or "foo.hpp" (depending on
your file naming convention).

But usually for both template implementations and inline function
implementations, I've seen the implementations in the "foo.h" (or "foo.hpp")
itself.

HTH,
--Eljay



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux