[freetds] FreeTDS, C++, and Exceptions

Frediano Ziglio freddyz77 at tin.it
Sat Jun 17 11:34:49 EDT 2006


Il giorno sab, 17/06/2006 alle 03.55 -0400, Lenon Kitchens ha scritto:
> Hi folks,
> 
> I have a problem with FreeTDS that I was hoping someone could help me 
> solve.  I'm a developer for a company that deals in network management 
> software.  Since basically all of our applications need to have the 
> ability to talk to one or more of SQLServer, Oracle, SQLite, Sybase,  I 
> have written a C++ library to provide a common interface to all of these 
> APIs.
> 
> It wasn't until recently that I noticed a problem with the FreeTDS part 
> of my implementation.  I have installed error and message handlers using 
> dberrhandle() and dbmsghandle().  At the end of each of these functions, 
> I throw an exception like so:
> 
> throw DBLibException(EGENERAL_EXCEPTION, err.str());
> 

:( this is bad C++... a C callback implemented in C++ should not throw
exceptions... C do not support unwinding so you are doing something
wrong. You could recompile all FreeTDS using a C++ compiled but code is
not exception safe (cause C do not support exception) so you would
convert a core in leaks... you should save error in a place, and outside
FreeTDS detect this error and throw exception.

bye
  freddy77





More information about the FreeTDS mailing list