简体   繁体   English

Tesseract baseapi错误:'strncpy':此函数或变量可能不安全。 考虑改用strncpy_s

[英]Tesseract baseapi error: 'strncpy':this function or variable may be unsafe. Consider using strncpy_s instead

I get the above mentioned error when I use the following in Visual Studio 2012(I am using C++): 当我在Visual Studio 2012中使用以下代码时,出现上述错误(我使用的是C ++):

#include <tesseract\baseapi.h>

Could anyone shed some light on what may be wrong? 任何人都可以阐明可能出什么问题吗?

Non secure CRT functions are deprecated by default. 默认情况下,不建议使用不安全的CRT功能。 You can enable them back by defining the macro _CRT_SECURE_NO_WARNINGS . 您可以通过定义宏_CRT_SECURE_NO_WARNINGS来启用它们。 Try - 尝试-

#define _CRT_SECURE_NO_WARNINGS
#include <tesseract\baseapi.h>

Or add the macro to the project properties list. 或将宏添加到项目属性列表。 Read the article Eliminating Deprecation Warnings at MSDN. 阅读MSDN上的文章“ 消除弃用警告”

From the article - 从文章-

There are several ways to eliminate deprecation warnings for the older, less secure functions. 有多种方法可以消除较旧,安全性较低的功能的弃用警告。 The simplest is simply to define _CRT_SECURE_NO_WARNINGS or use the warning pragma. 最简单的方法就是定义_CRT_SECURE_NO_WARNINGS或使用警告编译指示。 Either will disable deprecation warnings, but of course the security issues that caused the warnings still exist. 两者都将禁用过时警告,但是导致警告的安全问题当然仍然存在。 It is far better to leave deprecation warnings enabled and take advantage of the new CRT security features. 最好不要启用弃用警告并利用新的CRT安全功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM