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?
4

4 に答える 4

1

このエラーが表示されるのは、speech_tools の abort() 関数が標準で義務付けられている abort() 関数と競合するためです。これを修正するための本当に良い、きれいな方法はおそらくないでしょう。EST_String.h を自分で作成した場合は、関数に別の名前を付けます。

そうでない場合は、同じファイルに stdlib.h と EST_String.h を含めないでください。はい、それは制限的で悪いことですが、ここではひどい状況にあります.

于 2011-11-14T13:48:17.790 に答える
0

これは非常に基本的な c エラーです。中止の 2 つの定義が矛盾しています。行を削除してEST_String.h、おそらく a を追加し、#include <stdlib.h>その後コンパイルされるかどうかを確認します。

于 2011-11-14T13:46:26.800 に答える
0

stdlib ヘッダーを含めることが問題だとは思いません。ただし、翻訳単位の最初のヘッダーとしてまたは のいずれ <cstdlib> を含めることで、マイレージが向上する場合があります。<stdlib.h>

根拠: の定義が<cstdlib>no-throw declspec を追加する場合に備えて。

だから私は本当にお勧めします...ただそれをいじってください。どちらの方法でも機能しない場合 (競合するインクルードや古いプリコンパイル済みヘッダーがないことを確認してください)、EST_String.h で問題のある宣言を削除することをお勧めします。

于 2011-11-14T13:50:58.663 に答える