C++ : if I don't like the name of a command...

Community Forums/General Help/C++ : if I don't like the name of a command...

Robert Cummings(Posted 2009) [#1]
... is it possible to rename it in C++ using something called a macro or something without a speed loss?


ie...

Function thingy(a)
{
poo(b);
}

but without the function call overhead, ie some kind of preprocessor so that whenever I write thingy, the compiler puts poo there instead?


N(Posted 2009) [#2]
#define A B

Replaces A with B. So..
#define foo bar

transforms
foo(1, 2, 3)

into
bar(1, 2, 3)


Generally not a good idea to do this though, since it'll make your code very confusing when you have to look up what a macro does when you can't remember its purpose.


Robert Cummings(Posted 2009) [#3]
Thanks a lot :) I am a stubborn git tho... gotta make wheels square sometimes.


D4NM4N(Posted 2009) [#4]
Defines seem to disable intellisense too in many IDEs.
I prefer the wrapper approach although theres probably a minute speed loss over several looped hits. (although i am a relative noob so what do i know :)


Gabriel(Posted 2009) [#5]
I prefer the wrapper approach although theres probably a minute speed loss over several looped hits. (although i am a relative noob so what do i know :)

Bit of a noob to C++ myself, but if you 'inline'ed those wrapper functions, wouldn't that eliminate the speed loss? I know technically inline is only a suggestion that the compiler can ignore, but that doesn't seem to happen very often, and inline is intended for very short functions as with a wrapper.


D4NM4N(Posted 2009) [#6]
Hmmm.. handy to know :), Might be useful for my c++ "b3dlikeeasyirrlicht" wrapper thingy i am making.