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. COM
  4. Forward declaration of interfaces

Forward declaration of interfaces

Scheduled Pinned Locked Moved COM
c++help
7 Posts 4 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.
  • R Offline
    R Offline
    Rowan Seymour
    wrote on last edited by
    #1

    I have 2 interfaces that reference each other (A & B) and the MIDL compiler is not happy... :-( in A's header file... __interface IA : IDispatch { [id(1), helpstring("")] HRESULT func([in] IB* pB); }; in B's header file... __interface IB : IDispatch { [id(1), helpstring("")] HRESULT func([in] IB* pB); }; if i don't forward declare the interfaces I get a C++ syntax error if i forward declare the interfaces with the __interface keyword, I get: error MIDL2025 : syntax error : expecting a type specification near "IImageHSV" if i forward declare the interfaces with the interface keyword, I get: error MIDL2003 : redefinition : IImageHSV Any suggestions much appreciated

    V B A 3 Replies Last reply
    0
    • R Rowan Seymour

      I have 2 interfaces that reference each other (A & B) and the MIDL compiler is not happy... :-( in A's header file... __interface IA : IDispatch { [id(1), helpstring("")] HRESULT func([in] IB* pB); }; in B's header file... __interface IB : IDispatch { [id(1), helpstring("")] HRESULT func([in] IB* pB); }; if i don't forward declare the interfaces I get a C++ syntax error if i forward declare the interfaces with the __interface keyword, I get: error MIDL2025 : syntax error : expecting a type specification near "IImageHSV" if i forward declare the interfaces with the interface keyword, I get: error MIDL2003 : redefinition : IImageHSV Any suggestions much appreciated

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      Try using a different ID. Kuphryn

      R 1 Reply Last reply
      0
      • V valikac

        Try using a different ID. Kuphryn

        R Offline
        R Offline
        Rowan Seymour
        wrote on last edited by
        #3

        You mean a different GUID? Can a forward declaration have a GUID? Don't think so... Why isn't everyone having this problem :-D ?

        1 Reply Last reply
        0
        • R Rowan Seymour

          I have 2 interfaces that reference each other (A & B) and the MIDL compiler is not happy... :-( in A's header file... __interface IA : IDispatch { [id(1), helpstring("")] HRESULT func([in] IB* pB); }; in B's header file... __interface IB : IDispatch { [id(1), helpstring("")] HRESULT func([in] IB* pB); }; if i don't forward declare the interfaces I get a C++ syntax error if i forward declare the interfaces with the __interface keyword, I get: error MIDL2025 : syntax error : expecting a type specification near "IImageHSV" if i forward declare the interfaces with the interface keyword, I get: error MIDL2003 : redefinition : IImageHSV Any suggestions much appreciated

          B Offline
          B Offline
          Brian Shifrin
          wrote on last edited by
          #4

          I do that all the time [uuid(... ] library MyCoolLib { interface IB; [ object, uuid(...),dual...] interface IA : IDispatch { [id(1), helpstring("")] HRESULT func([in] IB* pB); }; [ object, uuid(...),dual...] interface IB : IDispatch { [id(1), helpstring("")] HRESULT func([in] IA* pB); };

          R 1 Reply Last reply
          0
          • B Brian Shifrin

            I do that all the time [uuid(... ] library MyCoolLib { interface IB; [ object, uuid(...),dual...] interface IA : IDispatch { [id(1), helpstring("")] HRESULT func([in] IB* pB); }; [ object, uuid(...),dual...] interface IB : IDispatch { [id(1), helpstring("")] HRESULT func([in] IA* pB); };

            R Offline
            R Offline
            Rowan Seymour
            wrote on last edited by
            #5

            I'm using the ATL Wizard in VS.NET which puts the IDL and C++ in the same file, so I have to use the __interface keyword, which I think is the problem because the MIDL compiler doesn't recognize the forward declaration using __interface. Maybe. Arrghh. :)

            1 Reply Last reply
            0
            • R Rowan Seymour

              I have 2 interfaces that reference each other (A & B) and the MIDL compiler is not happy... :-( in A's header file... __interface IA : IDispatch { [id(1), helpstring("")] HRESULT func([in] IB* pB); }; in B's header file... __interface IB : IDispatch { [id(1), helpstring("")] HRESULT func([in] IB* pB); }; if i don't forward declare the interfaces I get a C++ syntax error if i forward declare the interfaces with the __interface keyword, I get: error MIDL2025 : syntax error : expecting a type specification near "IImageHSV" if i forward declare the interfaces with the interface keyword, I get: error MIDL2003 : redefinition : IImageHSV Any suggestions much appreciated

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

              I am facing the same problem and have not able to find out any solution yet. I tried inserting interface declaration statements in IDL file using "cpp_quote" attribute also but that does not work even (it inserts the line including "cpp_quote" :() Rowan, have you been able to find out any solution yet. If you had already, do post it... it would be a great help ! Thanx & Regards, Arun.

              R 1 Reply Last reply
              0
              • A arun1405

                I am facing the same problem and have not able to find out any solution yet. I tried inserting interface declaration statements in IDL file using "cpp_quote" attribute also but that does not work even (it inserts the line including "cpp_quote" :() Rowan, have you been able to find out any solution yet. If you had already, do post it... it would be a great help ! Thanx & Regards, Arun.

                R Offline
                R Offline
                Rowan Seymour
                wrote on last edited by
                #7

                Alas I've given up trying - but I'll remember to put it here if I ever fix it

                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