Francisco J. Royo Santas wrote:
> Oh :(:( Thank you very much anyway, I hoped it could be possible. How
> can I do a C edge for a C++ class?
Francisco,
If I understand Eljay correctly, I think he means that you have to write
something like the following:
linuxobject.h
-------------
extern "C" void* createLinuxObject();
extern "C" int callLinuxObjectMethod1( void* linuxObject );
extern "C" int callLinuxObjectMethod2( void* linuxObject );
linuxobject.c
-------------
extern "C" void* createLinuxObject()
{
return (void*) new LinuxObject();
}
extern "C" int callLinuxObjectMethod1( void* linuxObject )
{
return ((LinuxObject*)linuxObject)->method1();
}
extern "C" int callLinuxObjectMethod2( void* linuxObject )
{
try
{
((LinuxObject*)linuxObject)->method2();
}
catch( ... )
{
return LINUX_OBJECT_FAILURE;
}
return LINUX_OBJECT_SUCCESS;
}
As you can see, you have to write C functions for every (externally
callable) method of your class, as well as a function to create an
object and probably one to destroy it as well.
The Visual C++ code would then have to call these C functions, rather
than interacting with your class directly. It is a little messy, but it
should work, since the C ABI *is* standardized across compilers.
But honestly, it sounds like it would be much less complicated to simply
compile your (Linux) code with Visual C++, as Eljay originally suggested.
--
Tony Wetmore
Solipsys Corporation (http://www.solipsys.com)
mailto:tony.wetmore@xxxxxxxxxxxx