Re: Convert GCC under Cygwin Name Mangling to VC++ Name Mangling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tony & Francisco,

Excellent example, Tony!  That's a good way to describe exactly what I
meant.

I like that you covered catching all exceptions converting them to some form
of error code.  And you have to do it for the createLinuxObject, too:

extern "C" void* createLinuxObject()
{
  try
  {
    return (void*) new LinuxObject();
  }
  catch(...)
  {
    return NULL;
  }
 }

And you'll need a release (or dispose or destruct or destory or whatever the
terminology one prefers) function too:

extern "C" int releaseLinuxObject(void* linuxObject)
{
  try
  {
    delete (LinuxObject*)linuxObject;
  }
  catch(...)
  {
    // What?  Throwing an exception in a destructor?  Very bad mojo indeed.
    return LINUX_OBJECT_FAILURE;
  }

  return LINUX_OBJECT_SUCCESS;
}

And quite possibly you may need an initialize and terminate for globals and
other prim-and-proper state for the LinuxObject system as a whole:

extern "C" int initializeLinuxObjectSystem();
extern "C" int terminateLinuxObjectSystem();

I recommend that the initialize / terminate either keep track of a counter
for proper nested initializations; or disallow them completely and fail with
an appropriate error code.  Bad mojo to allow multiple initializations and
only one termination.

Sincerely,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux