This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Body of inline function in cpp file and link time optimizations (LTO)
- From: "John (Eljay) Love-Jensen" <eljay at adobe dot com>
- To: Godlike God <godlike_panos_hot at hotmail dot com>, GCC-help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 16 Nov 2009 08:48:01 -0800
- Subject: Re: Body of inline function in cpp file and link time optimizations (LTO)
Hi Godlike God,
> For design reasons (circular dependency) I dont want the body of certain
> functions in the class definition. For example I DONT want this:
I have run into that same issue. The solution was to do this:
//----------------------------
// in vec2.h
#include "vec3.h"
class vec2_t
{
//...
vec2_t(vec3_t const& v3)
//...
};
#include "vec2.i.h"
//----------------------------
//----------------------------
// in vec2.i.h
inline
vec2_t::vec2_t(vec3_t const& v3)
:
v(v3.x),
v(v3.y)
{
}
//----------------------------
For my project, putting all the inlines in "foo.i.h" files was acceptable.
If your goal is to completely ferret away the inlines so that they are not
in the public headers (including the "really ought to be private but have to
be public inline headers" (*.i.h))... then this won't be sufficient.
If your goal is to have better segregation between "public headers" (with a
"no implementation in API public headers" type of policy), and "public
inline headers" (which I've designated with a .i.h double-extension -- your
convention may vary), then the above suggestion may be of some use for you.
I don't know the answers to your -flto questions.
HTH,
--Eljay