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.
LVL 2
livniAsked:
Who is Participating?
 
gvgConnect With a Mentor Commented:
Thanks Livni

I is totally up to you if I get points.  Only give them to me if I deserve them.

Happy coding.

Gunnar Valur

0
 
GlennDeanCommented:
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
   
0
 
livniAuthor Commented:
My structure has 10 parameters.
I gave here 2 parameters just for the sample...
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
gvgCommented:
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
0
 
livniAuthor Commented:
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.
0
 
gvgCommented:
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
0
 
livniAuthor Commented:
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.
0
 
gvgCommented:
As I said.  Type mismatch 8-)

Gunnar Valur
0
 
livniAuthor Commented:
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.
0
All Courses

From novice to tech pro — start learning today.