inline funcs
Im new to c++ and im not really sure if i got the inline function concept right. What i understood is that the inline keyword simply replaces the function call with the function code. The benefit should be that u dont waste time on function calls during runtime. Inline functions will however make the compiled exe bigger since some code is repeated. Right ?
Say i have a function i only call once every gameloop - like my UpdateFrame() - wouldnt it always be better to inline this function. I mean, this would mean that the function takes up twice the space (who cares), but should be - at least - a little faster ?
If i got this right i really cant see no reason not to inline functions that are repeated often.
Am i missing something ???
I would really appreciate if some1 could clear this up for me.
Thanx
yes thats basicly right. its a little faster then a non-inline... its only a good idea if the funcion is small(only a few lines long)...
Great Milenko
Great Milenko
Words Of Wisdom:
"Never Stick A Pretzel In Your Butt It Might Break Off In There."
http://www.crosswinds.net/~milenko
http://www.crosswinds.net/~pirotech
The Great Milenko"Don't stick a pretzel up your ass, it might get stuck in there.""Computer Programming is findding the right wrench to hammer in the correct screw."
most of my class functions are inline because most of them are short... (1-2 lines, usually in ASM) but when i go through the disesemble in debug.. it still calls a function and pushes all of the regester and then pops them at the end... but this is retarded because i only use eax... so how exactly do you declare member functions as inline... and why does inlining screw w/ the cache?
ThanX,
RanXacT
ThanX,
RanXacT
RanXact@yahoo.com
In debug mode, inlining is disabled. Compile your program in release mode and then the inlining will work.
http://mazurek.dhs.org/3d/
http://mazurek.dhs.org/3d/
What do you change to compile something in Release Mode?
THANKS A LOT!
later,
THANKS A LOT!
later,
Dude, if you have UpdateFrame() that''s called once each frame, there is nothing wrong with making it inline, except for the fact that it will make the code bigger, but give you no advantage whatsoever The time needed for the function call is very small, and if the function is called once each frame, this time is negligible. You should use inline function while doing data processing, for example, if you do alpha blending, and you call a function 100,000 times a frame, then you inline it.
February 29, 2000 11:46 PM
quote: Original post by Esap1
What do you change to compile something in Release Mode?
THANKS A LOT!
later,
In VC++5.0 or 6.0 go to Build->Set Active Configuration and set eh configuration to release. This will build an executable in the release directory under your project.
Be sure to set your link and C++ tabs properly in the Project-Settings dialog. Hope this helps.
Kressilac
Thanks Anonymous Poster(get a name, its free), And the Release runs faster, so my game should hit the 150fps mark(hehe)
Inline functions are only for very small routines that you commonly call. It is totally up to the compiler if the function will actually be inlined. You adding the inline keyword is really only an attempt to inline.
You will get no speed increase by inlining your Updateframe() function because it will probably be way to big as it will call other larger functions. I can''t remember correctly, but I don''t think you can inline a function that calls another function.
An example of an inline function would be one that subtracts two variables and returns true if the result is negitive.
I haven''t used an inline function in a while so you better check this with your compilers documentation.
You will get no speed increase by inlining your Updateframe() function because it will probably be way to big as it will call other larger functions. I can''t remember correctly, but I don''t think you can inline a function that calls another function.
An example of an inline function would be one that subtracts two variables and returns true if the result is negitive.
I haven''t used an inline function in a while so you better check this with your compilers documentation.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement