MIDL: Compilation Error
-
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
-
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
-
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 { ... };
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
-
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
Add forward declarations: interface IMyInterface; <- to OtherInterface.idl interface IOtherInterface <- to MyInterface.idl
-
Add forward declarations: interface IMyInterface; <- to OtherInterface.idl interface IOtherInterface <- to MyInterface.idl
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