0

vi 例子.c

#include<stdio.h>
#include "flite.h"
register_cmu_us_kal();
int main(int argc,char** argv)
{
 cst_voice *v;
 if(argc!=2)
 {
  fprintf(stderr,"usage:file_test FILE\n");
  exit(-1);
 }
 flite_init();
 v=register_cmu_us_kal(NULL);
 flite_file_to_speech(argv[1],v,"play");
 return 0;
}

编译:桌面:

~/flite-1.4-release$ gcc example.c -I./include/ -L./build/i386-linux-gnu/lib -lflite -lflite_cmu_us_kal -lflite_cmulex -lflite_usenglish -lflite_cmu_us_rms -lflite_cmu_time_awb -lflite_cmu_us_slt -lflite_cmu_us_awb -lm -o example


example.c:3: warning: data definition has no type or storage class
example.c: In function ‘main’:
example.c:13: warning: assignment makes pointer from integer without a cast

我已经探索了下面的 lib 文件夹的内容。

桌面:

~/flite-1.4-release$ ls
ACKNOWLEDGEMENTS  config.guess   configure     example          flite.sln   lang      mkinstalldirs  src        wince
bin               config.log     configure.in  example.c        -I          main      palm           testsuite  windows
build             config.status  COPYING       Exports.def      include     Makefile  README         test.txt
config            config.sub     doc           fliteDll.vcproj  install-sh  missing   sapi           tools

桌面:

~/flite-1.4-release/build/i386-linux-gnu/lib$ ls
libflite.a                      libflite_cmu_us_awb.shared.a    libflite_cmu_us_kal.so.1      libflite.shared.a
libflite_cmulex.a               libflite_cmu_us_awb.so          libflite_cmu_us_kal.so.1.4    libflite.so
libflite_cmulex.shared.a        libflite_cmu_us_awb.so.1        libflite_cmu_us_rms.a         libflite.so.1
libflite_cmulex.so              libflite_cmu_us_awb.so.1.4      libflite_cmu_us_rms.shared.a  libflite.so.1.4
libflite_cmulex.so.1            libflite_cmu_us_kal16.a         libflite_cmu_us_rms.so        libflite_usenglish.a
libflite_cmulex.so.1.4          libflite_cmu_us_kal16.shared.a  libflite_cmu_us_rms.so.1      libflite_usenglish.shared.a
libflite_cmu_time_awb.a         libflite_cmu_us_kal16.so        libflite_cmu_us_rms.so.1.4    libflite_usenglish.so
libflite_cmu_time_awb.shared.a  libflite_cmu_us_kal16.so.1      libflite_cmu_us_slt.a         libflite_usenglish.so.1
libflite_cmu_time_awb.so        libflite_cmu_us_kal16.so.1.4    libflite_cmu_us_slt.shared.a  libflite_usenglish.so.1.4
libflite_cmu_time_awb.so.1      libflite_cmu_us_kal.a           libflite_cmu_us_slt.so
libflite_cmu_time_awb.so.1.4    libflite_cmu_us_kal.shared.a    libflite_cmu_us_slt.so.1
libflite_cmu_us_awb.a           libflite_cmu_us_kal.so          libflite_cmu_us_slt.so.1.4

请帮我解决这个问题。

4

2 回答 2

3

以下声明了一个接受未指定参数并返回的函数int

register_cmu_us_kal();

当你调用它时,你将它的结果分配给一个类型的变量cst_voice*

v=register_cmu_us_kal(NULL);

编译器会就此转换向您发出警告。

我认为最好的做法是为register_cmu_us_kal(也许通过包含相关的头文件)提供适当的原型。

于 2011-12-14T15:40:50.163 回答
2

您可以通过更改方法声明来解决此问题:

register_cmu_us_kal();

cst_voice *register_cmu_us_kal();

这告诉编译器该方法 register_cmu_us_kal();返回 acst_voice *而不是默认的 an int,当您分配 this 时:

v = register_cmu_us_kal(NULL);

首先,您使用参数调用函数,而您在没有参数的情况下定义它,其次它警告您正在尝试将 a 分配int给 a cst_voice *

于 2011-12-14T15:41:49.570 回答