Skip to main content
gamedev.net
🔒 Locked

About inline functions.

Started by Brobanx 4 replies 250+ views
Original Post
Brobanx
Brobanx
If I were to call the following function, am I correct to assume that it would take no cycles to call the function since it''s inline, and does nothing?
  
inline void doesNothing() { }
[\source]  
ironfroggy
ironfroggy
I think that would be up to the compiler, but it would be best for it to compile to nothing I would hope.

// God.c
void main() {
WORLD Earth;
LIFE People = Earth.CreateLife(HUMAN);
GiveHope(&People);
delete Earth;
EvilCackle();
}
(http://www.ironfroggy.com/)(http://www.ironfroggy.com/pinch)
EvilCrap
EvilCrap
thats dependent on the compiler,
but,
i think that most compilers would not allot any space for that function address, and therefore not call it, in essece accidentally optimizing it out.
though it could be possible for the compiler to cause an overlap, so that when you called donothing, you would actually call some other function. compilers are usually smarter than this though.
Beer Hunter
Beer Hunter
If it wasn''t inline, then it might count as a function call under a non-optimising compiler, but since it''s inline, it won''t, even in the most braindead compiler.

If you want to waste CPU cycles, you could just throw in:

__asm { nop };

...which shouldn''t get optimised out.
EvilCrap
EvilCrap
/doh
i must have blocked out the inline in my prev post.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.