Hi,
Sorry for putting such a stupid problem to the eyes of the respected
qualified public.
Last time I wrote:
>> I have some problems with accessing calling "QueryInterface".
>> Is there an example of working with all these USB structures from C++?
"email@hidden" answered:
> Are you using Apple C++ (from ProjectBuilder) or Metrowerks C++
> from CodeWarrior? Is your C++ app CFM?
I am using both, MW C++ for the "Big Application" (which is CFM), and an
Apple C/C++ bundle for USB access when launched under the OSX.
First I tried wrapping USB access into MW C/C++ and after a lot of efforts
changed the approach to separate these OSX-only calls into a mach-0 bundle.
It looks like a good solution.
Generally this approach works, I have got most of pieces of code working for
the big app from the bundle (in plain C). Finally it is a mix of C and C++
(with some extern "C" tricks), I tested various aspects of this mix - it
works, too.
The problem arose when I started to assemble those pieces together, wrapping
various plain C tasks into classes/objects.
The problem (I found a working workaround, but I would love to find a simple
correct way to do the things...) is like that (Apple C++):
// I try to get IOUSBInterface from a device reference returned from
// IOGetMatchingServices. That piece of code worked fine in plain C.
//
// Omitting details, the C++ method where I have problems looks like this:
//
// aClass::Method( io_service_t devRef)
// {
// IOCFPlugInInterface **iodev;
// IOUSBDeviceInterface **dev;
// ...
//
// IOCreatePlugInInterfaceForService(devRef,
// CFUUIDGetUUIDBytes(...),
// &iodev, &score);
//
// err = (*iodev)->QueryInterface(iodev, CFUUIDGetUUIDBytes(...),
// (LPVOID)&dev);//here I can't compile
// ...
// }
//
The diagnostic tells "ANSI C++ forbids implicit conversions from "void*" in
argument passing". I would be happy to know, where such conversion could
happen, since I pass arguments some of which are typed differently from what
the plain-C interface wanted. (As far as I can see, I did not enforce any
"strict ansi" anywhere - Apple C++ diagnostics and flags are a nice saga of
its own.)
QueryInterface expects a void *thisPointer where I pass it a
"IOCFPlugInInterface **", but it would be rather a conversion "to void*"
than "from void*". I tried to cast iodev in various ways to "void*", and it
drives me mad when I think there must be an easy variant I just did not
find. (Does it want a void**?)
Well, I tried a complete C++ way to do the things (IUnknown) too, but
without significant success, due to my stupidity or to the "red eyes
status" of the project... And since I did not try such way before (it has
some peculiarities of its own).
Now the bundle starts to look like a multi-layered sandwich (C-interface to
communicate with the big app, then C++ complex of classes, calling here and
there another level of C routines to do some house-keeping... While a coffee
break I even thought about putting some of my code as Objective-C, a
language I did not try for "bread and butter projects" yet - at least that
uses plain C linkage and is another great way to organize code...)
Sorry for putting such a stupid problem to the eyes of the respected
qualified public.
Best regards
Thanks in advance for any suggestions
OIeg
_______________________________________________
usb mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/usb
Do not post admin requests to the list. They will be ignored.