inline void doesNothing() { }
[\source]
About inline functions.
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?
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();
}
// God.c
void main() {
WORLD Earth;
LIFE People = Earth.CreateLife(HUMAN);
GiveHope(&People);
delete Earth;
EvilCackle();
}
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.
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.
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.
If you want to waste CPU cycles, you could just throw in:
__asm { nop };
...which shouldn''t get optimised out.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement