I'm working on a legacy c++ COM project that I'm moving over to Visual Studio 2010. In the IDL file for this project, I have to reference an ODL file from another c++ project. My problem is that the other project generates its header file as $(filename)_h.h. When my IDL file generates its header file, it generates the ODL filename as $filename.h, and it can't reference the correct file.
In other words, in my IDL file ("MyIDLFile.idl") I have a statement like
import "MyODLFile.odl"
which in the generated file ("MyIDLFile.h") becomes
when I need it to generate
How do I specify the file name I want the IDL to generate in an import statement?
This is a common problem to solve when dealing with IDL files. The good thing is that there are a few ways to solve this problem:
Your ultimate solution may use a little of #1 and #2.
The MIDL compiler has several options to modify the names of output files, or excluding output files.
Directly specifying names:
-OUTPUT FILE NAMES-
/cstub filename Specify client stub file name
/dlldata filename Specify dlldata file name
/h filename Specify header file name
/header filename Specify header file name
/iid filename Specify interface UUID file name
/proxy filename Specify proxy file name
/sstub filename Specify server stub file name
/tlb filename Specify type library file name
Skipping output files:
-OUTPUT FILE GENERATION-
/client none Do not generate client files
/server none Generate no server files
/notlb Don't generate the tlb file
I personally have used the /prefix option to avoid name collisions of headers in the past.
/no_default_epv Do not generate a default entry-point vector
/prefix client str Add "str" prefix to client-side entry points
/prefix server str Add "str" prefix to server-side manager routines
/prefix switch str Add "str" prefix to switch routine prototypes
/prefix all str Add "str" prefix to all routines
This is an example of that:
/prefix client HIDE_
The interface with method foo would be renamed to HIDE_foo in the header.
The other strategy that works is related to how you layer your directories, build order, and publish files, and use include paths, and order the actual includes. I am only used to using sources with dir files, and build.exe, so I can't give any advice how that works with VS.
I'm not sure what you mean about the import statement, but what you're looking for might be found under the project's Properties. Goto the properties window (Alt-F7) and under "Configuration Properties/MIDL/Output", you'll have the opportunity to declare the Header File which you want it to create. Since your project is legacy, it may be easier to just remove the "_h" from the header file name (e.g. $(ProjectName).h instead of $(ProjectName)_h.h). See http://support.microsoft.com/kb/321274 for a lil more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With