`byte' typedef?

Robert J. Hansen rjhansen at inav.net
Mon Jul 1 13:25:02 CEST 2002


WK> Other languages should only use the published interface and never make
WK> use of the actual code.

It's not a matter of my C++ bindings making use of the actual code;
it's a matter of compiling GPGME with a C++ compiler so that I can
throw exceptions through GPGME.

The following pseudocode is very tongue in cheek, but should show basically
what the problem is.

Stuff foo()
{
  if (programmer->IQ == 0) throw new ProgrammerReallyDumb;

  return SomeStuff
}

void bar()
{
  gpgme_do_something_with_stuff(foo()) // calling out to a C library
}

void baz()
{
  try {
    bar()
  }
  catch (ProgrammerReallyDumb* moron)
  {
    moron->insult("Ren&Stimpy-YouEeeeediot!.wav");
    delete moron;
  }
}


... Now let's say Engine::baz() gets called.  It'll never catch the
ProgrammerReallyDumb exception that Engine::foo() throws, because
somewhere along the line it passed control off to a C function which
wasn't exception-aware.  The solution: compile GPGME with a C++
compiler... but that requires old-fashioned casts, not implicit void*
conversion.

I understand that this is not a priority for GPGME, and I'm not trying
to suggest that it should be.  I'm just pointing out that using
implicit void* conversion in lieu of explicit casts is not a clear-cut
win; it tends to complicate interoperability with other languages
which demand typesafety.

This isn't a purely academic issue, BTW--Gtkmm programmers are
restricted to local exception handling for exactly this reason.





More information about the Gnupg-devel mailing list