[Expat-discuss] c++-ize expat
Graham Bennett
graham-expat at simulcra.org
Wed Jun 25 00:29:01 EDT 2003
On Tue, Jun 24, 2003 at 02:38:21PM +0200, m. wrote:
> Hello.. I am wondering whether it is possible to c++-ize expat's code
> so that it could be compiled with c++ compiler. The reason for this
> is the ability to throw exceptions from callback functions. I have to
> remove all the 'extern "C"' stuff from expat code and cast all the
> void* to FILE* and so on.. Could this be done in the default expat's
> code?
In order to use expat from C++ code it is not necessary to compile with
g++. All that you need is to compile with gcc with the -fexceptions
flag. This generates the necessary stack unwinding code to allow
exceptions to be thrown.
IIRC, the expat configure script will enable the -fexceptions flag if it
detects the compiler is gcc (even though it checks for -fno-exceptions).
Try it and see.
I have used expat from C++ code compiled in this way and I've had no
problems throwing exceptions through expat code.
cheers,
--
Graham Bennett
More information about the Expat-discuss
mailing list