Body of inline function in cpp file and link time optimizations (LTO)

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

 



For design reasons (circular dependency) I dont want the body of certain functions in the class definition. For example I DONT want this:

// in vec2.h file:
...
class vec2_t
{
    ...
    inline vec2_t( const vec3_t& v3 ): x(v3.x), y(v3.y) {}
    ...
};
...


But instead I WANT this:


// in vec2.h file:
...
class vec2_t
{
    ...
    vec2_t( const vec3_t& v3 );
    ...
};
...

// in vec2.cpp file:
...
vec2_t::vec2_t( const vec3_t& v3 ): x(v3.x), y(v3.y) 
{}
...


I know that its good practice to make the small functions inline but in my case I cannot. 

First question: Will gcc be able to understand and make this kind of small functions inline (with -O3 for example)? 

I read about Link Time Optimizations and -flto but it seems this is a new feature (I cannot use it yet). 

Second question: If I convert my code and ditch every inline I have, will -flto make the small functions inline for me?


Thanks in advance!
 		 	   		  
_________________________________________________________________
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010


[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