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. Keywords that I don't understand

Keywords that I don't understand

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestionlearning
33 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.
  • S Stephen Hewitt

    No one says macros should never be used, just that they shouldn’t be used when other superior constructs exist for the same task; the specific example in this case is that macros should not be used as inline functions. I have constantly argued the point, complete with examples and data (compiler output) to support my claims; while you seem intent on arguing the person and accusing people of missing the point. Well I've had my say and I'll let my comments speak for themselves.

    Steve

    J Offline
    J Offline
    Jeremy Falcon
    wrote on last edited by
    #24

    Stephen Hewitt wrote:

    No one says macros should never be used, just that they shouldn’t be use when other superior constructs exist for the same task; the specific example in this case is that macros should not be used as inline functions.

    I'm sorry you don't understand context - my bad. I'll have to remember that next time I write something.

    Stephen Hewitt wrote:

    I have constantly argued the point, complete with examples and data (compiler output) to support my claims;

    And that makes you correct how?

    Stephen Hewitt wrote:

    while you seem intent on arguing the person and accusing people of missing the point. Well I've had my say and I'll let my comments speak for themselves.

    Fair enough, but don't accuse me of what you did, and that is to argue a point I never spoke against. Have a nice day.

    Jeremy Falcon "It's a good thing to do and a tasty way to do it." - Wilford Brimley[^]

    1 Reply Last reply
    0
    • S Stephen Hewitt

      No one says macros should never be used, just that they shouldn’t be used when other superior constructs exist for the same task; the specific example in this case is that macros should not be used as inline functions. I have constantly argued the point, complete with examples and data (compiler output) to support my claims; while you seem intent on arguing the person and accusing people of missing the point. Well I've had my say and I'll let my comments speak for themselves.

      Steve

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #25

      Stephen Hewitt wrote:

      No one says macros should never be used, just that they shouldn’t be use when other superior constructs exist for the same task; the specific example in this case is that macros should not be used as inline functions.

      Actually, I just reread what I said. I did mention inline functions. Perhaps you should bother reading my posts... oh wait.

      Jeremy Falcon "It's a good thing to do and a tasty way to do it." - Wilford Brimley[^]

      1 Reply Last reply
      0
      • L Lost User

        Jeremy Falcon wrote:

        Tell me then, since he designed C++, why didn't he drop macro support if he loathed the mere existence of them that much? Compatibility can't be the reason as it was a brand new language at the time, and wouldn't effect C. I can understand making it completely compile C code, but why not specify compilers replace macros with something else under the hood, etc. I mean, why keep them if they're so bad?

        Obviously I could only speculate at this and that would be pointless. It is my preference to avoid macros whenever possible.

        J Offline
        J Offline
        Jeremy Falcon
        wrote on last edited by
        #26

        Josh Gray wrote:

        Obviously I could only speculate at this and that would be pointless. It is my preference to avoid macros whenever possible.

        Well, let's make a deal. I won't hold it against you if you don't hold it against me for sneaking the occasional macro or two in some code when you're not looking. :-D

        Jeremy Falcon "It's a good thing to do and a tasty way to do it." - Wilford Brimley[^]

        L 1 Reply Last reply
        0
        • J Jeremy Falcon

          Josh Gray wrote:

          Obviously I could only speculate at this and that would be pointless. It is my preference to avoid macros whenever possible.

          Well, let's make a deal. I won't hold it against you if you don't hold it against me for sneaking the occasional macro or two in some code when you're not looking. :-D

          Jeremy Falcon "It's a good thing to do and a tasty way to do it." - Wilford Brimley[^]

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #27

          Jeremy Falcon wrote:

          if you don't hold it against me for sneaking the occasional macro or two in some code when you're not looking.

          Its a long piece of rope, you do what you like with it

          1 Reply Last reply
          0
          • J Jeremy Falcon

            Christian Graus wrote:

            inline is a *suggestion* to the compiler that this function is so simple

            I hate to use your post, but that's a great reason I forgot. There is no real guarantee inline will even work. You're guaranteed to have inline expansion with macros though. Man, old age is getting to me. :-O

            Jeremy Falcon "It's a good thing to do and a tasty way to do it." - Wilford Brimley[^]

            S Offline
            S Offline
            Stephen Hewitt
            wrote on last edited by
            #28

            The only times I've seen MSVC ignore an inline directive is when its had no choice such as with recursive functions: in this context this is a feature.

            Steve

            J 1 Reply Last reply
            0
            • S Stephen Hewitt

              The only times I've seen MSVC ignore an inline directive is when its had no choice such as with recursive functions: in this context this is a feature.

              Steve

              J Offline
              J Offline
              Jeremy Falcon
              wrote on last edited by
              #29

              Stephen Hewitt wrote:

              The only times I've seen MSVC ignore an inline directive is when its had no choice such as with recursive functions: in this context this is a feature.

              And MSVC is the only compiler in existence too.

              Jeremy Falcon "It's a good thing to do and a tasty way to do it." - Wilford Brimley[^]

              S 1 Reply Last reply
              0
              • J Jeremy Falcon

                Stephen Hewitt wrote:

                The only times I've seen MSVC ignore an inline directive is when its had no choice such as with recursive functions: in this context this is a feature.

                And MSVC is the only compiler in existence too.

                Jeremy Falcon "It's a good thing to do and a tasty way to do it." - Wilford Brimley[^]

                S Offline
                S Offline
                Stephen Hewitt
                wrote on last edited by
                #30

                No, it isn't. Until recently it was one of the worst (MSVC 6) in common use. I have inspected the machine code generated by MSVC 6 (I do a lot of postmortem debugging at work) and the inlining works as expected except when that’s not possible, as I mentioned before. The Microsoft compilers after MSVC 6 produce even better code from what I’ve seen. All modern C++ compiler support inlining just fine.

                Steve

                L J 2 Replies Last reply
                0
                • S Stephen Hewitt

                  No, it isn't. Until recently it was one of the worst (MSVC 6) in common use. I have inspected the machine code generated by MSVC 6 (I do a lot of postmortem debugging at work) and the inlining works as expected except when that’s not possible, as I mentioned before. The Microsoft compilers after MSVC 6 produce even better code from what I’ve seen. All modern C++ compiler support inlining just fine.

                  Steve

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #31

                  And some even inline code without you asking for it if the optimisation is set right :)

                  S 1 Reply Last reply
                  0
                  • L Lost User

                    And some even inline code without you asking for it if the optimisation is set right :)

                    S Offline
                    S Offline
                    Stephen Hewitt
                    wrote on last edited by
                    #32

                    On MSVC this can be controlled with the /Ob[^] compiler switch.

                    Steve

                    1 Reply Last reply
                    0
                    • S Stephen Hewitt

                      No, it isn't. Until recently it was one of the worst (MSVC 6) in common use. I have inspected the machine code generated by MSVC 6 (I do a lot of postmortem debugging at work) and the inlining works as expected except when that’s not possible, as I mentioned before. The Microsoft compilers after MSVC 6 produce even better code from what I’ve seen. All modern C++ compiler support inlining just fine.

                      Steve

                      J Offline
                      J Offline
                      Jeremy Falcon
                      wrote on last edited by
                      #33

                      Stephen Hewitt wrote:

                      Until recently it was one of the worst (MSVC 6) in common use. I have inspected the machine code generated by MSVC 6 (I do a lot of postmortem debugging at work) and the inlining works as expected except when that’s not possible, as I mentioned before. The Microsoft compilers after MSVC 6 produce even better code from what I’ve seen.

                      And you just felt the need to say this right? I don't really see how this has anything to do with the point that was quoted - which I'm sure you could've guessed is sarcasm.

                      Stephen Hewitt wrote:

                      All modern C++ compiler support inlining just fine.

                      Nice blanket statement there. Notice the extra little comments in these links that have nothing to do with recursion. http://gcc.gnu.org/onlinedocs/gcc/Inline.html[^] http://www.osc.edu/hpc/manuals/ia64/docs2/c_ug_lnx.pdf[^] I don't know about you, but it seems easier to me to just use a macro rather than learn all the quirks of every compiler in the world.

                      Jeremy Falcon "It's a good thing to do and a tasty way to do it." - Wilford Brimley[^]

                      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