Re: Problem with class operators.

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

 



Hi Kristian,

> What is now my conclusion : put small methods into the class decleration.
> But this looks dirty (sorry, but I try to hold my code clean).

Yes, put the non-specialized template method definitions in the header file.
That is where they belong.

You are not keeping your code clean by moving the non-specialized template
methods to a .cpp file.

Although if you REALLY want to do something like that to keep those things
separated, I highly recommend putting your non-specialized template methods,
along with your (explicitly) inline functions, into a file with the
extension .inl and then include that file at the end of your .h file.

For example:

----- foo.h -----
#ifndef foo_h_once
#define foo_h_once

// blah blah blah

#include "foo.inl"
#endif
-----------------

> Is no other way, to stop gcc to inline small methods ?

q.v. these switches

-Winline                    Warn when an inlined function cannot be inlined
-finline                    Pay attention to the "inline" keyword
-finline-functions          Integrate simple functions into their callers
-finline-limit-             This switch lacks documentation
-finline-limit=<number>     Limit the size of inlined functions to <number>
-fkeep-inline-functions     Generate code for functions even if they are
                              fully inlined
-fobey-inline               Obey 'inline' keyword and always inline,
max-inline-insns-single     The maximum number of instructions in a single
max-inline-insns-auto       The maximum number of instructions when
max-inline-insns-recursive  The maximum number of instructions inline
max-inline-insns-recursive-auto The maximum number of instructions
non-inline
max-inline-recursive-depth  The maximum depth of recursive inlining for
                              inline functions
max-inline-recursive-depth-auto The maximum depth of recursive inlining for
                              non-inline functions
inline-unit-growth          how much can given compilation unit grow because
inline-call-cost            expense of call operation relative to ordinary
-fdefault-inline            Inline member functions by default
-fimplement-inlines         Export functions even if they can be inlined
-fimplicit-inline-templates Emit implicit instantiations of inline templates
-fvisibility-inlines-hidden Marks all inlined methods as having hidden
-fdefault-inline, -fdollars-in-identifiers, -felide-constructors,
-fhandle-exceptions, -fhonor-std, -fhuge-objects, -fimplement-inlines,
-fimplicit-inline-templates, -fimplicit-templates, -finput-charset=,
-fvisibility-inlines-hidden, -fvtable-gc, -fvtable-thunks, -fweak,

I produced this list via:

gcc -v --help >gcc.help 2>&1
grep inline gcc.help

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