Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MACRO vs INLINE FUNCTION

MACRO vs INLINE FUNCTION

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiotestingbeta-testingperformance
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    avenger_sb25
    wrote on last edited by
    #1

    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

    M C G 3 Replies Last reply
    0
    • A avenger_sb25

      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

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • M Maximilien

        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

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        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)

        1 Reply Last reply
        0
        • A avenger_sb25

          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

          C Offline
          C Offline
          Curi0us_George
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • A avenger_sb25

            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

            G Offline
            G Offline
            Gary R Wheeler
            wrote on last edited by
            #5

            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;

            A 1 Reply Last reply
            0
            • G Gary R Wheeler

              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;

              A Offline
              A Offline
              avenger_sb25
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups