3

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?
Christian Rau
  • 45,360
  • 10
  • 108
  • 185
Sriram
  • 10,298
  • 21
  • 83
  • 136
  • 1
    Can you create a minimal example? – BЈовић Nov 14 '11 at 13:46
  • 1
    that's nice and catch-22. I assume you can make it `extern "C" void abort(void) throw();`? That would be a funny paradox, since C doesn't know exceptions – sehe Nov 14 '11 at 13:46
  • @VJo: The example I used can be had here: http://festvox.org/docs/manual-1.4.3/festival_28.html#SEC133 - the `main()` function is the same as that on the page. Linking and compilation instructions are also found on that. – Sriram Nov 14 '11 at 13:50
  • @sehe: That is what I tried after coming across some posts which said that the original definition of `abort()` throws while this does not.. That did not work either, I ended with `undefined reference to` errors. – Sriram Nov 14 '11 at 13:51

4 Answers4

1

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.

thiton
  • 35,651
  • 4
  • 70
  • 100
0

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
0

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.

plaisthos
  • 6,255
  • 6
  • 35
  • 63
  • nope. Commenting that line in `EST_String.h` and including `stdlib.h` removed that one, but introduced a whole host of other `undefined reference to` errors. `EST_String.h` is a file that comes with the Festival distribution. – Sriram Nov 14 '11 at 13:48
0

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

sehe
  • 374,641
  • 47
  • 450
  • 633
  • Can you please edit your answer in the `including either or as the ...` part? I think you had written something here in your comment but it might have been accidentally left out. – Sriram Nov 14 '11 at 13:57
  • Adding `#include ` or `#include ` as the very first header in the file does not make any difference to the error message. – Sriram Nov 14 '11 at 14:03
  • @Sriram: of course I meant _exclusively_. **NOT** 'adding'. Adding it will only make sure of conflicting declarations. My bet is on removing the declaration from `EST_String.h`, because it really has no business there: it belongs in system headers (stdlib.h/cstdlib) – sehe Nov 14 '11 at 14:04
  • OK. So does this mean that after I change something in the header, I need to recompile Festival or at least "speech_tools", which is the project where this header is? – Sriram Nov 14 '11 at 14:14
  • No.               – sehe Nov 14 '11 at 14:16