vi example.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
请帮我解决这个问题。
答案 0 :(得分:3)
以下声明了一个带有未指定参数的函数,并返回int
:
register_cmu_us_kal();
调用它时,将其结果分配给cst_voice*
类型的变量:
v=register_cmu_us_kal(NULL);
编译器会警告您此转换。
我认为最好的做法是为register_cmu_us_kal
提供适当的原型(可能包括相关的头文件)。
答案 1 :(得分:2)
您可以通过更改方法声明来解决此问题:
register_cmu_us_kal();
要
cst_voice *register_cmu_us_kal();
这告诉编译器方法
register_cmu_us_kal();
返回cst_voice *
而不是int
这是默认值,当你指定它时:
v = register_cmu_us_kal(NULL);
首先,您使用参数调用函数,无需参数即可定义参数;其次,它会警告您尝试将int
分配给cst_voice *
。