Link to home
Start Free TrialLog in
Avatar of livni
livni

asked on

IDL - structures as parameters

I added to my IDL file the following structure: (it's a com custom interface ATL object)
 
typedef struct _MyStructure {
    char a;
    char b;
} MyStructure;
 
this structure is used as one of the [in] parameters of one of the method's in my object's interface.
 
When I "rebuild all" my dll, the idl file seems OK', but I get strange errors:
 
error c2259: 'CComObject<class CMyClass> : cannot instantiate abstract class due to the following members:....
while compiling class-template member function 'long __stdcall ATL::CComCreator<class ATL::CComObject<class MyClass>>::CreateInstance(void *,const struct _GUID &, void **)'
blah
blah
blah...
 
Again: When I just create an ATL project and adds an ATL object - it works fine.
But when I add this structure-based parameters - I get the compilation errors.
Am I using the structure incorrectly ?
How should I use it ?
I'd like a code sample please.
Avatar of GlennDean
GlennDean

livni:
   I created an ATL project and added to the IDL your struct (nothing else) and I got a laundry list of errors.
   I know this isn't a solution nor answer, but in this case why can't you just have 2 [in] parameters, one for the first character and another for the second character?  Atleast with known types, you don't have to worry about proxy/stub stuff (just put oleautomation in your IDL).
  Glenn
   
Avatar of livni

ASKER

My structure has 10 parameters.
I gave here 2 parameters just for the sample...
This error is generated when the CPP file containing the implimentation fo the COM object does not contain the function you defined in the IDL file.

Due to the following members...

Tells you which members are the one you are not implimenting.

Double check all your parameters in the header file and the CPP file and then it should work.

I tried this with an ATL project and it worked fine.

Hope this helps.

Gunnar Valur
Avatar of livni

ASKER

I doubled check them.
All are implemented.
There's probably a problem with the way I'm passing the structure as parameter.
I'm gonna try pass a pointer to the struct instead of the struct by value and see how it goes.
I am almost sure that this error is due to mismatch between IDL and the CPP implimentation because I have fought this error way to often. 8-)

This error also often occures if you for example have moved the IDL generated header file and an old copy lies somewhere.

If you send me the error message, the IDL file, the object header and cpp file I would be happy to check this out for you.  My e-mail is gvg@flaga.is.

Gunnar Valur
Avatar of livni

ASKER

Problem solved.
The error is occured because when I use char type in the idl file, it is translated to unsigned char on the cpp file, and leaves the h file with char.

if I change the h to unsigned char too,
then the function won't appear under the Interface on the class list.

Solution - using CHAR type will do the job.
As I said.  Type mismatch 8-)

Gunnar Valur
Avatar of livni

ASKER

gvg.
The fact that this is a type mismatch is understandable from the compiler error lines.
I couldn't understand WHAT is the mismatch. that's why i double-checked everything.
If you still think you deserve the points - post an answer. I won't argue.
ASKER CERTIFIED SOLUTION
Avatar of gvg
gvg

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial