MACRO vs INLINE FUNCTION
-
Hi geeks,:suss: Please tell me when to use a MACRO and when to use an INLINE FUNCTION in C++. If this question has been asked before, please point me to that link. I need an answer comparing the two. Please dont post definitions of macro and inline function as i am aware of them. Please give the answer in terms of efficiency, speed, code-size, pre-compilation/post-compilation, and things like that. And please give examples ... :rose: ...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
-
Hi geeks,:suss: Please tell me when to use a MACRO and when to use an INLINE FUNCTION in C++. If this question has been asked before, please point me to that link. I need an answer comparing the two. Please dont post definitions of macro and inline function as i am aware of them. Please give the answer in terms of efficiency, speed, code-size, pre-compilation/post-compilation, and things like that. And please give examples ... :rose: ...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
always use inline ( or ordinary methods ). the only reason I can give is that macros are preprocessor stuff and are not "debuggable"
Maximilien Lincourt Your Head A Splode - Strong Bad
-
always use inline ( or ordinary methods ). the only reason I can give is that macros are preprocessor stuff and are not "debuggable"
Maximilien Lincourt Your Head A Splode - Strong Bad
Maximilien wrote: the only reason I can give is that macros ... are not "debuggable" That should be reason enough. Very few things should exist as a preprocessor macro. The ability to type-check parameters is a must.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Hi geeks,:suss: Please tell me when to use a MACRO and when to use an INLINE FUNCTION in C++. If this question has been asked before, please point me to that link. I need an answer comparing the two. Please dont post definitions of macro and inline function as i am aware of them. Please give the answer in terms of efficiency, speed, code-size, pre-compilation/post-compilation, and things like that. And please give examples ... :rose: ...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
My general rule is that if it can be done as an inline function, it should be. There are some things which cannot be done with an inline function, but can be done with a macro. Those are rare, though.
-
Hi geeks,:suss: Please tell me when to use a MACRO and when to use an INLINE FUNCTION in C++. If this question has been asked before, please point me to that link. I need an answer comparing the two. Please dont post definitions of macro and inline function as i am aware of them. Please give the answer in terms of efficiency, speed, code-size, pre-compilation/post-compilation, and things like that. And please give examples ... :rose: ...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
avenger_sb25 wrote: Hi geeks,:suss: That's a wee bit rude, don't you think? avenger_sb25 wrote: I need an answer comparing the two. Please dont post definitions of macro and inline function as i am aware of them. Please give the answer in terms of efficiency, speed, code-size, pre-compilation/post-compilation, and things like that. And please give examples ... This sounds suspiciously like you've got a take-home exam in a programming course, and you're looking for us 'geeks' to provide the answers. I'll give you the answer to your question. My rate is $75USD/hr (you're getting the student discount, BTW), 4 hours minimum, in advance, in cash.
Software Zen:
delete this;
-
avenger_sb25 wrote: Hi geeks,:suss: That's a wee bit rude, don't you think? avenger_sb25 wrote: I need an answer comparing the two. Please dont post definitions of macro and inline function as i am aware of them. Please give the answer in terms of efficiency, speed, code-size, pre-compilation/post-compilation, and things like that. And please give examples ... This sounds suspiciously like you've got a take-home exam in a programming course, and you're looking for us 'geeks' to provide the answers. I'll give you the answer to your question. My rate is $75USD/hr (you're getting the student discount, BTW), 4 hours minimum, in advance, in cash.
Software Zen:
delete this;
Is that something you say when you dont know the answer Mr? Anyway a proper answer would have been appreciated. I was asked this questionj at a job interview. When i will get the job, i will pay u. LOL ...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs