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. MIDL: Compilation Error

MIDL: Compilation Error

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
5 Posts 3 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
    Ahsan Abbas
    wrote on last edited by
    #1

    Hi All, I am working on a project(.dsp in Visual C++ 6.0) which has multiple .idl files, many of these .idl files has cross reference. Actually what I mean is, a function inside file1's interface(interface_of_file1) takes a parameter of file2's interface(interface_of_file2). Plus, a function in interface_of_file2 takes parameter of interface_of_file1. I hope you people got the idea that both files need the other file to be compiled. In this situation, if I import file2 in file1 and compile file1, compiler tries to compile file2 first and gives error that: error MIDL2025 : syntax error : expecting a type specification near "interface_of_file1" . Now this is a kind of Dead Lock. I did Forward declaration instead of importing the file(I do not exactly know the method offorward declaration in MIDL). I did it in file1 like: interface interface_of_file2; Now this gives a different error and a warning: ============================================== error MIDL2011 : unresolved type declaration : interface_of_file2 [ Parameter 'parameter1' of Procedure 'get_CashPeriod' ( Interface 'interface_of_file1' ) ] warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'parameter1' of Procedure 'get_CashPeriod' ( Interface 'interface_of_file1' ) ] ============================================== Now please tell me, whether I'm doing forward declaration wrongly? or can anyone suggest some other solution to this problem? I will be really thankful for any good answer. Regards, Ahsan Ahsan

    T 1 Reply Last reply
    0
    • A Ahsan Abbas

      Hi All, I am working on a project(.dsp in Visual C++ 6.0) which has multiple .idl files, many of these .idl files has cross reference. Actually what I mean is, a function inside file1's interface(interface_of_file1) takes a parameter of file2's interface(interface_of_file2). Plus, a function in interface_of_file2 takes parameter of interface_of_file1. I hope you people got the idea that both files need the other file to be compiled. In this situation, if I import file2 in file1 and compile file1, compiler tries to compile file2 first and gives error that: error MIDL2025 : syntax error : expecting a type specification near "interface_of_file1" . Now this is a kind of Dead Lock. I did Forward declaration instead of importing the file(I do not exactly know the method offorward declaration in MIDL). I did it in file1 like: interface interface_of_file2; Now this gives a different error and a warning: ============================================== error MIDL2011 : unresolved type declaration : interface_of_file2 [ Parameter 'parameter1' of Procedure 'get_CashPeriod' ( Interface 'interface_of_file1' ) ] warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter 'parameter1' of Procedure 'get_CashPeriod' ( Interface 'interface_of_file1' ) ] ============================================== Now please tell me, whether I'm doing forward declaration wrongly? or can anyone suggest some other solution to this problem? I will be really thankful for any good answer. Regards, Ahsan Ahsan

      T Offline
      T Offline
      tomiczek
      wrote on last edited by
      #2

      why don't you import the idl-file where the referenced interface is declared as you do with normal C++ header? e.g. import "YourInterface.idl"; ... ... the you can use it... interface IOtherInterface : IYourInterface { ... };

      A 1 Reply Last reply
      0
      • T tomiczek

        why don't you import the idl-file where the referenced interface is declared as you do with normal C++ header? e.g. import "YourInterface.idl"; ... ... the you can use it... interface IOtherInterface : IYourInterface { ... };

        A Offline
        A Offline
        Ahsan Abbas
        wrote on last edited by
        #3

        I have already done it the way you are saying. I tried to say the same thing in my question. I have imported the "MyInterface.idl" in "OtherInterface.idl". But when I import MyInterface.idl, MIDL compiler goes and compiles "MyInterface.idl" first. Now problem starts here, "MyInterface.idl" also uses "OtherInterface.idl". Let me write the scenario in the form of code, this might be better understandable. ======================== Start of MyInterface.idl ======================== import "oaidl.idl"; import "OtherInterface.idl"; [ uuid(072C0C51-426B-1ED2-B2DF-0060085FAE21), dual, helpstring ("IMyInterface Interface"), pointer_default (unique) ] interface IMyInterface: IDispatch { [id(0), propget] HRESULT EventID ([out, retval] IOtherInterface** pvKey); } ====================== End of MyInterface.idl ====================== =========================== Start of OtherInterface.idl =========================== import "oaidl.idl"; import "MyInterface.idl"; [ uuid(073D0C21-466A-11D2-A2DF-0050485CFE7B), dual, helpstring ("IOtherInterface Interface"), pointer_default (unique) ] interface IOtherInterface: IDispatch { [id(0), propget] HRESULT EventID ([out, retval] IMyInterface** pipSeg); } ========================= End of OtherInterface.idl ========================= Now, you people may know my problem, that both files are needing the other file. This has become a dead-lock. To compile any of the both files I will need to compile the imported file. I hope you understood. Now, can anyone help me out? :'( Ahsan

        B 1 Reply Last reply
        0
        • A Ahsan Abbas

          I have already done it the way you are saying. I tried to say the same thing in my question. I have imported the "MyInterface.idl" in "OtherInterface.idl". But when I import MyInterface.idl, MIDL compiler goes and compiles "MyInterface.idl" first. Now problem starts here, "MyInterface.idl" also uses "OtherInterface.idl". Let me write the scenario in the form of code, this might be better understandable. ======================== Start of MyInterface.idl ======================== import "oaidl.idl"; import "OtherInterface.idl"; [ uuid(072C0C51-426B-1ED2-B2DF-0060085FAE21), dual, helpstring ("IMyInterface Interface"), pointer_default (unique) ] interface IMyInterface: IDispatch { [id(0), propget] HRESULT EventID ([out, retval] IOtherInterface** pvKey); } ====================== End of MyInterface.idl ====================== =========================== Start of OtherInterface.idl =========================== import "oaidl.idl"; import "MyInterface.idl"; [ uuid(073D0C21-466A-11D2-A2DF-0050485CFE7B), dual, helpstring ("IOtherInterface Interface"), pointer_default (unique) ] interface IOtherInterface: IDispatch { [id(0), propget] HRESULT EventID ([out, retval] IMyInterface** pipSeg); } ========================= End of OtherInterface.idl ========================= Now, you people may know my problem, that both files are needing the other file. This has become a dead-lock. To compile any of the both files I will need to compile the imported file. I hope you understood. Now, can anyone help me out? :'( Ahsan

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

          Add forward declarations: interface IMyInterface; <- to OtherInterface.idl interface IOtherInterface <- to MyInterface.idl

          A 1 Reply Last reply
          0
          • B Brian Shifrin

            Add forward declarations: interface IMyInterface; <- to OtherInterface.idl interface IOtherInterface <- to MyInterface.idl

            A Offline
            A Offline
            Ahsan Abbas
            wrote on last edited by
            #5

            I think, I have understood the original problem now. I gave the forward declarations in one of the .idl files. On compiling it gave the error: ======================================================== error MIDL2011 : unresolved type declaration : IOtherInterface [ Parameter 'pipSegment' of Procedure 'get_CSegment' ( Interface 'IMyInterface' ) ] ======================================================== When I double-clicked over the error, to see where exactly it occured. VC++ gave a message box with the text as below: ======================================================= "C:\MyWorspace\Infrastructure\MyUtils\IMyInterface.idl" Cannot open file. File not found. ======================================================= While this interface file is actually at: C:\MyWorspace\Business Tier\Objects\IMyInterface.idl Now, VC is not picking the path correctly. Even I have opened the file in the editor, which is even showing correct directory on clicking "Save As" from File menu). Now, PLEASE tell me, where do I may correct this path, so that file file may work correctly. Regards, Ahsan:confused: Ahsan

            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