odl or idl?
I have two projects that I am maintaining, both of which have COM
interfaces. One of the projects has an odl file with all of the
interface definitions in it and the other project has an idl.
I have been able to add enums to the idl file (that have generated .h
files automatically) so that I can #include and then use the enum in
the C++ prototypes within the project.
The project with the odl file doesn't seem to work the same. I can
add the enum to the odl file and change the interface prototypes to
use the enum, but no .h files are being generated so when I change the
c++ prototypes I get errors saying that I have an unexpected type (I
had to typedef the enum to get this far) Just to add to the confusion
the odl project uses MFC heavily and the odl file has AFX_ODL_PROP /
AFX_ODL_METHOD macros in it.
What is the difference between an idl and an odl file? The impression
I get is that odl files are obsolete, but can I just do a straight
swap for an idl? I tried this and class wizard fails plus it doesn't
seem to fix the problem.
I have noticed that the MIDL compiler on the odl project is set to
MkTypLib compatible mode. Also both projects are C++ and are using
Visual C++ 6.
To be honest I'm not sure if the problem is with MFC, ODL, IDL or me!
Ok some code snippets. This is from the odl project I cannot get to
compile. You will notice I use the typedef and enum keyword in
various places. Some articles seem to say I need to typedef enum and
others say this is not necessary. I'm really unsure what is needed as
far as the odl goes.
cpp file contains -
DISP_FUNCTION(CEdDoc, "SetDefaultPos", SetDefaultPos, VT_EMPTY, enum
ValidPositions) // This fails
h file -
class CEdDoc : public CDocument
// code removed for clarity
// Generated OLE dispatch map functions
afx_msg void SetDefaultPos(enum ValidPositions pos);
odl file -
[ uuid(19838AA2-0DBD-11D5-8A1D-0048548D8E8C), version(1.1) ]
typedef enum ValidPositions
CurrentPos = 0,
HighPos = 1,
MediumPos = 2,
LowPos = 3
// Primary dispatch interface for CEdDoc
[ uuid(F526EC6C-09C5-4217-BC0F-53E7296476FC) ]
[id(33)] void SetDefaultPos(ValidPositions pos);
[ uuid(2F6B315D-0D97-11D5-8A1D-0048548D8E8C) ]
[default] dispinterface IEd;