On Tue, Jun 28, 2011 at 8:55 PM, Charles Samuels <char...@cariden.com>wrote:

> However, be warned that if you use exceptions, you can't use sqlite3_exec,
> because then the exceptions can't make it through the C code. It's easy
> enough
> to roll your own sqlite3_exec and compile it as C++.
>

To expand upon that a bit...

It's generally considered bad practice to allow C++ exceptions to "cross
module boundaries", so if you're linking to sqlite3.dll/so and exec calls
your callback, it has cross such a boundary. As a general rule, one should
not allow any exceptions to go back across that boundary. If you do, you've
entered the world of undefined behaviour. In my experience it actually works
with 3rd-party C++ libraries on Linux systems, but it's not guaranteed to as
far as i understand. Then again, dlsym() (which plays are part in most
DLL-loading code on Unix-like system) relies on undefined behaviour (casting
a (void*) to a function and dereferencing it), and its use is still
prevelant (and works, despite The Standard). i.e. it works, but it's not
really guaranteed to. Kinda like email, i guess.

The legendary Herb Sutter wrote about it in "C++ Coding Standards", if i'm
not mistaken.

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to