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. Other Discussions
  3. Clever Code
  4. Listen to what the compiler is saying...

Listen to what the compiler is saying...

Scheduled Pinned Locked Moved Clever Code
question
6 Posts 5 Posters 4 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
    Antony M Kancidrowski
    wrote on last edited by
    #1

    We can all have one of those days, this must have been one of them! Code: DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4, VTS_BSTR) Compiler: warning C4002: too many actual parameters for macro 'DISP_FUNCTION' A few cross words and pointing at other lines of code saying "Look, those have more parameters! What is wrong with you?". And also after a hour or so of wondering what day it was and whether I should have stayed in bed, I finally spotted it. Solution: DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4 VTS_BSTR) There is a subtle difference. Notice the absence of the "," between VTS_UI4 and VTS_BSTR. Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)

    Ant. I'm hard, yet soft.
    I'm coloured, yet clear.
    I'm fruity and sweet.
    I'm jelly, what am I? Muse on it further, I shall return!
    - David Walliams (Little Britain)

    E M R J 4 Replies Last reply
    0
    • A Antony M Kancidrowski

      We can all have one of those days, this must have been one of them! Code: DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4, VTS_BSTR) Compiler: warning C4002: too many actual parameters for macro 'DISP_FUNCTION' A few cross words and pointing at other lines of code saying "Look, those have more parameters! What is wrong with you?". And also after a hour or so of wondering what day it was and whether I should have stayed in bed, I finally spotted it. Solution: DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4 VTS_BSTR) There is a subtle difference. Notice the absence of the "," between VTS_UI4 and VTS_BSTR. Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)

      Ant. I'm hard, yet soft.
      I'm coloured, yet clear.
      I'm fruity and sweet.
      I'm jelly, what am I? Muse on it further, I shall return!
      - David Walliams (Little Britain)

      E Offline
      E Offline
      Ed Poore
      wrote on last edited by
      #2

      Antony M Kancidrowski wrote:

      Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)

      At least they tend to be consistent liars ;)


      If you're stuck in a rut: 1) Consult the documentation* 2) Google it 3) Ask a sensible question 4) Try an ancient ritualistic knowledge summoning (:badger::badger::badger:) dance :jig: 5) Phone :bob: * - If the documentation is MSDN > 6.0 then forget it!

      1 Reply Last reply
      0
      • A Antony M Kancidrowski

        We can all have one of those days, this must have been one of them! Code: DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4, VTS_BSTR) Compiler: warning C4002: too many actual parameters for macro 'DISP_FUNCTION' A few cross words and pointing at other lines of code saying "Look, those have more parameters! What is wrong with you?". And also after a hour or so of wondering what day it was and whether I should have stayed in bed, I finally spotted it. Solution: DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4 VTS_BSTR) There is a subtle difference. Notice the absence of the "," between VTS_UI4 and VTS_BSTR. Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)

        Ant. I'm hard, yet soft.
        I'm coloured, yet clear.
        I'm fruity and sweet.
        I'm jelly, what am I? Muse on it further, I shall return!
        - David Walliams (Little Britain)

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        MFC dispatch macros are particularly nasty. That particular piece of weirdness comes from the fact that C++ doesn't have varargs macros; to make it possible to build the table, the last argument is a string. This takes advantage of the fact that in C and C++, two adjacent strings in the source are concatenated together to form a single string by the compiler. The MFC IDispatch implementation then parses the string to figure out what the argument types are and how to pass them to the called function. ATL simply hands the whole job off to the standard type-library-based implementation of IDispatch. You can do this in MFC by following the steps in this KB article[^].

        Stability. What an interesting concept. -- Chris Maunder

        A 1 Reply Last reply
        0
        • M Mike Dimmick

          MFC dispatch macros are particularly nasty. That particular piece of weirdness comes from the fact that C++ doesn't have varargs macros; to make it possible to build the table, the last argument is a string. This takes advantage of the fact that in C and C++, two adjacent strings in the source are concatenated together to form a single string by the compiler. The MFC IDispatch implementation then parses the string to figure out what the argument types are and how to pass them to the called function. ATL simply hands the whole job off to the standard type-library-based implementation of IDispatch. You can do this in MFC by following the steps in this KB article[^].

          Stability. What an interesting concept. -- Chris Maunder

          A Offline
          A Offline
          Antony M Kancidrowski
          wrote on last edited by
          #4

          Thanks for this link Mike. I will certainly need to read that through a couple of times in order to really understand it. Printing it as I type. :)

          Ant. I'm hard, yet soft.
          I'm coloured, yet clear.
          I'm fruity and sweet.
          I'm jelly, what am I? Muse on it further, I shall return!
          - David Walliams (Little Britain)

          1 Reply Last reply
          0
          • A Antony M Kancidrowski

            We can all have one of those days, this must have been one of them! Code: DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4, VTS_BSTR) Compiler: warning C4002: too many actual parameters for macro 'DISP_FUNCTION' A few cross words and pointing at other lines of code saying "Look, those have more parameters! What is wrong with you?". And also after a hour or so of wondering what day it was and whether I should have stayed in bed, I finally spotted it. Solution: DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4 VTS_BSTR) There is a subtle difference. Notice the absence of the "," between VTS_UI4 and VTS_BSTR. Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)

            Ant. I'm hard, yet soft.
            I'm coloured, yet clear.
            I'm fruity and sweet.
            I'm jelly, what am I? Muse on it further, I shall return!
            - David Walliams (Little Britain)

            R Offline
            R Offline
            Ray Kinsella
            wrote on last edited by
            #5

            Those MFC macros are sooooooo easy to mess up, and the hell of it is that they are alway ok in the Debug Build but always crash in the Release Build ...

            Regards Ray "Je Suis Mort De Rire" Blogging @ Keratoconus Watch

            1 Reply Last reply
            0
            • A Antony M Kancidrowski

              We can all have one of those days, this must have been one of them! Code: DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4, VTS_BSTR) Compiler: warning C4002: too many actual parameters for macro 'DISP_FUNCTION' A few cross words and pointing at other lines of code saying "Look, those have more parameters! What is wrong with you?". And also after a hour or so of wondering what day it was and whether I should have stayed in bed, I finally spotted it. Solution: DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4 VTS_BSTR) There is a subtle difference. Notice the absence of the "," between VTS_UI4 and VTS_BSTR. Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)

              Ant. I'm hard, yet soft.
              I'm coloured, yet clear.
              I'm fruity and sweet.
              I'm jelly, what am I? Muse on it further, I shall return!
              - David Walliams (Little Britain)

              J Offline
              J Offline
              jhwurmbach
              wrote on last edited by
              #6

              Antony M Kancidrowski wrote:

              We can all have one of those days, this must have been one of them!

              That so good with those days: there are enough of them for anyone...:laugh:


              "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

              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