Declaration of void abort() throws different exceptions

1.4k Views Asked by At

I am trying to write some C++ code (using the C++ API) for Festival and am getting stuck while trying to compile. Here is how I invoke g++:

g++ -Wall -pedantic -I../ -I../speech_tools/include/ helloFestival.C -o h -L../festival/src/lib/libFestival.a -L../speech_tools/lib/libestools.a -L../speech_tools/lib/libestbase.a -L../speech_tools/lib/libeststrings.a |& tee festival.runLog The error I get is:

In file included from ../speech_tools/include/EST.h:48,
                 from ../festival/src/include/festival.h:47,
                 from helloFestival.C:4:
../speech_tools/include/EST_String.h:50: error: declaration of ‘void abort()’ throws different exceptions
/usr/include/stdlib.h:513: error: from previous declaration ‘void abort() throw ()’

The offending line in EST_String.h would be:
extern "C" void abort(void);

The main() function I have used can be found here: festvox.org/docs/manual-1.4.3/festival_28.html#SEC133

The compilation and linking instructions given here are the ones I have used.

I have looked this problem on the net and some of the solutions suggest that it maybe because of backward compatibility, or calling an abort() from within a destructor etc. My questions are:

  1. How do I get rid of this?
  2. Why do I see this error?
4

There are 4 best solutions below

0
On

This is still a problem today. As a workaround, i'm using this piece of code. It's ugly and hacky, but gets it working:

extern "C" void abort_est() { abort(); }
#define abort abort_est
#include <festival.h>
#undef abort
1
On

It is a very basic c error. The two definition for abort are conflicting I would try to remove the line in EST_String.h and maybe add a #include <stdlib.h> and see if it compiles after that.

3
On

You see this error because the abort() function in speech_tools conflicts with the standard-mandated abort() function. There's probably no really good, clean way to fix this. If you have written EST_String.h yourself, name the function differently.

If not, don't include stdlib.h and EST_String.h in the same file. Yes, that's limiting and bad, but you are in a crappy situation here.

5
On

I don't suppose including the stdlib header is the problem. However, you might get better mileage from including either <cstdlib> or <stdlib.h> as the very first header in your translation units

Rationale: just in case the definition in <cstdlib> adds the no-throw declspec.

So I really suggest to ... just fiddle with that. If it doesn't work either way (make sure you don't have conflicting includes or stale precompiled headers), I suggest just removing the offending declarion in EST_String.h