This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]