gpt4 book ai didi

c++ - void abort() 的声明抛出不同的异常

转载 作者:太空狗 更新时间:2023-10-29 23:08:48 27 4
gpt4 key购买 nike

我正在尝试为 Festival 编写一些 C++ 代码(使用 C++ API),但在尝试编译时卡住了。下面是我如何调用 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我得到的错误是:

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 ()’

EST_String.h 中有问题的行是:
extern "C"void abort(void);

我用过的main()函数可以在这里找到:festvox.org/docs/manual-1.4.3/festival_28.html#SEC133

这里给出的编译和链接说明是我用过的。

我在网上看过这个问题,一些解决方案表明它可能是因为向后兼容,或者从析构函数中调用 abort() 等。我的问题是:

  1. 我该如何摆脱它?
  2. 为什么我会看到这个错误?

最佳答案

您看到此错误是因为 speech_tools 中的 abort() 函数与标准强制的 abort() 函数冲突。可能没有真正好的、干净的方法来解决这个问题。如果您自己编写了 EST_String.h,请以不同的方式命名该函数。

如果不是,请不要在同一个文件中包含 stdlib.h 和 EST_String.h。是的,这是有限且糟糕的,但你在这里的处境很糟糕。

关于c++ - void abort() 的声明抛出不同的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8122478/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com