If i use macros as functions , then at compilation time , that macros will me be written as function code. so is it better than inline functions and then why don't we use macro always to write the functions as it will speed up our execution. so writing macro may increase time at compilation time, but shouldn't it help at execution time as we are saving our overheads in the funtionc calling. I know i am wrong some-where, so can you please correct me ? thanks.
nitin1 15 Master Poster
Recommended Answers
Jump to Postinline functions, the compiler can choose to make them inline as if they had been macros or to just make them regular functions. inline functions as well as functions written as macros has the potential to bloat the compiled program, making it a lot larger than if the function had …
Jump to PostYou should never prefer macros over inline functions. The only case where you'd use macros would be if you're writing for a compiler that does not support inline functions¹ or you're using macros as something other than a poor man's inline functions² - though even then you should think about …
Jump to PostOne thing that should be noted is that the compiler can inline functions even when they're not declared as inline when it thinks doing so will be appropriate.
Also,
inline
is nothing more than a hint. The compiler is free to ignore it. That's one benefit (in a …
All 10 Replies
Adak 419 Nearly a Posting Virtuoso
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
nitin1 15 Master Poster
sepp2k 378 Practically a Master Poster
nitin1 commented: from where you guys come to know about all these things, you are filled-up with loads of knowledge. :D +3
sepp2k 378 Practically a Master Poster
nitin1 15 Master Poster
nitin1 15 Master Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
nitin1 commented: awesome!! your way of explanation suits my understanding very much... +3
sepp2k 378 Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.