PDA

View Full Version : The use of inline functions



ada
08-01-2002, 05:13 PM
Hi.
It is posible to use inline functions?
I mean if a function contains one or more opengl functions call, does the compiler make it inline? Or if I force that this function to be inline it will be faster?
Thanks.

SirKnight
08-01-2002, 05:35 PM
It is posible to use inline functions?


Um.....yeah, using the inline keyword does wonders.



I mean if a function contains one or more opengl functions call, does the compiler make it inline?


No and why would it? Does the compiler do this for any other functions you have ever used?



Or if I force that this function to be inline it will be faster?


Depends. Probably not though.

Might I suggest going to http://www.cprogramming.com

-SirKnight

ada
08-01-2002, 05:48 PM
quote:
--------------------------------------------------------------------------------

I mean if a function contains one or more opengl functions call, does the compiler make it inline?

--------------------------------------------------------------------------------

No and why would it? Does the compiler do this for any other functions you have ever used?
****************************************
Because I said so. If I say "inline ... function(...){....}" this function is not necesary inline; the compiler will decide if the function is suitable for making inline or not. I asked if a function contains one or more gl call, is this function simple enoght to make it inline?

quote:
--------------------------------------------------------------------------------

Or if I force that this function to be inline it will be faster?

--------------------------------------------------------------------------------

Depends. Probably not though.

Might I suggest going to http://www.cprogramming.com
************************************
Thanks I'll check.
-SirKnight

Bob
08-02-2002, 01:19 AM
I asked if a function contains one or more gl call, is this function simple enoght to make it inline?

Do you ask if a function like this will be inlined?



inline void my2xVertex3fv(const float *v1, const float v2)
{
glVertex3fv(v1);
glVertex3fv(v2);
}

The I assume it will be inlined. What is inlined and what is not is generally up to the compiler to decide, and if you are unsure, just compile and look at the assembly output. If there is a function call in the resulting assebly code, it's not inlined.