VS2005下调用MS Speech API 5.1, 在添加“sphelper.h”头文件出现的问题,及解决方法

原创 2007年09月17日 12:35:00

在利用微软的SAPI开发语音合成程序,当添加头文件#include "sphelper.h"时出现了类似下面的error和warning: 

 

1>c:/program files/microsoft speech sdk 5.1/include/spdebug.h(274) : warning C4996: 'wcscpy' was declared deprecated
1> c:/program files/microsoft visual studio 8/vc/include/string.h(250) : see declaration of 'wcscpy'
1> Message: 'This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(89) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(150) : warning C4267: 'return' : conversion from 'size_t' to 'unsigned int', possible loss of data
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(169) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(226) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(227) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(334) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(769) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(769) : warning C4267: 'initializing' : conversion from 'size_t' to 'const int', possible loss of data
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(772) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(1419) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(2373) : error C2065: 'psz' : undeclared identifier
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(2544) : warning C4267: '+=' : conversion from 'size_t' to 'ULONG', possible loss of data
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(2559) : error C2440: 'initializing' : cannot convert from 'CSpDynamicString' to 'SPPHONEID *'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:/program files/microsoft speech sdk 5.1/include/sphelper.h(2633) : error C2664: 'wcslen' : cannot convert parameter 1 from 'SPPHONEID *' to 'const wchar_t *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

 

一开始,始终觉得是自己程序的问题,可找了半天还是没有找到原因,在网上搜索了一下,发现有不少网友曾遇到此类问题,可始终没有找到很好的解决办法。有位网友提出在vc6下下做个dll,然后放到vs2005下去调用,此方法不失为一个好方法。可还是不甘心,觉得太麻烦!继续搜索,终于在MS的论坛上发现一篇帖子是针对这个问题的,其中有位名叫Pete Baron 的网友提出了解决办法,个人觉得此方法比较方便实用,在此提供,以方便其他好友参考:

I'm not sure if these steps 'fix' the errors, but they permit the code to compile (honestly, I couldn't be bothered to try and decode the awful code in that file so I just used best-guess to what was intended in each case).  I didn't test speech-to-text, but the text-to-speech will definitely work correctly.

1) line 2560
    SPPHONEID* pphoneId = (SPPHONEID*)((WCHAR *)dsPhoneId);

2) line 2634
    pphoneId += wcslen((const wchar_t *)pphoneId) + 1;

3) line 2372 and 2373
        const WCHAR *psz;
        for (psz = (const WCHAR *)lParam; *psz; psz++) {}

4) add to the top of the file to prevent all the other errors...
#pragma warning( disable : 4430 )

I also added another line to prevent a stream of 'deprecated function' warnings
#pragma warning( disable : 4996 )



在使用VS2005 + DXSDK9 + XP编译WebRTC出现dxguid.lib(dxguid.obj) : debugging informati问题的解决方法

在使用VS2005 + DXSDK9 + XP编译WebRTC出现 2>dxguid.lib(dxguid.obj) : fatal error LNK1103: debugging informa...

Matlab2012生成DLL文件与VS2005(VC)混合编程解决方法(折腾两天的成果)

Matlab2012生成DLL文件与VS2005(VC)混合编程解决方法(折腾两天的成果) Matlab的版本太多,使用起来很麻烦,我使用过maltab2010b.2007b.都没有成功,最后装了m...

VS2005(c#)项目调试疑难问题解决方法锦集

1.在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: 命名管道提供程序,err...
  • fan325
  • fan325
  • 2011年10月14日 11:11
  • 876

vs2005 运行程序 出现没有找到MSVCP80D.dll 解决方法

没有找到MSVCP80D.dll 解决方法 在VS 2005中建立Win32工程时(以VS 2005中文版为例),你可能会遇到这样的运行错误:“没有找到MSVCP80D.dll,因此这个应用...

在VS2005中出现 "LC.exe"已退出,代码-1 的解决方法

原文网址:http://jcobra.blog.163.com/blog/static/470493200702910552928/ 在VS2005中出现 "LC.exe"已退出,代码-1 的解决方法...

项目由vs2005移植vs2010的问题及解决方法

项目由vs2005移植vs2010的问题及解决方法 一般情况下,由vs2005移植到vs2010是没有什么大问题,基本上都是小问题, 另外建议使用vs2010英文版,中文版不太习...

VC6 和 VS2003 转换到VS2005 时可能会遇到的问题以及解决方法

经常写VC工程的人都会遇到升级到VS2005时出现的各种各样的问题,下面写一些自己遇到的问题,还有什么不全的请大家补充。希望能给朋友们一些帮助。   VC6 和 VS2003 转换到VS2005 ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:VS2005下调用MS Speech API 5.1, 在添加“sphelper.h”头文件出现的问题,及解决方法
举报原因:
原因补充:

(最多只允许输入30个字)