Libtorrent:已声明不推荐使用的错误

Libtorrent : declared deprecated error

本文关键字:错误 声明 Libtorrent      更新时间:2023-10-16

以下行:

p.ti = new torrent_info(argv[1], ec);

显示以下错误:

error C4996: 'libtorrent::torrent_info::torrent_info': was declared deprecated

我该如何解决此问题?

您读过torrent_info.hpp中的注释吗?

    // all wstring APIs are deprecated since 0.16.11
    // instead, use the wchar -> utf8 conversion functions
    // and pass in utf8 strings

因此,您应该使用libtorrent提供的函数将宽字符argv[1]转换为UTF-8,然后从中构建torrent_info。

此消息通常只是一个警告,也许您有一个将警告视为错误的标志。尝试删除/WX编译器标志、Treat Warnings as Errors选项,或通过添加此标志或选项禁用此特定警告:/wd 4996。有关MSVC警告标志的详细信息。。。