使用“ -Wno弃用的”时,g ++不会忽略“弃用的声明” +“错误”的错误

时间:2018-11-14 13:35:13

标签: c++ compiler-errors g++ deprecated

与删除线案例相同。我有一个过时的函数调用,它给出了一个错误。我现在暂时忽略它。我可以使用#undef,但我更喜欢使用 "-Wno-deprecated" 编译标志,但是由于某些原因,我仍然会遇到相同的错误。

我有两个模块调用去皮功能蛋白:

SSH_DEPRECATED LIBSSH_API int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash);
// SSH_DEPRECATED == __attribute__ ((deprecated))
// as can be seen from:
//   #define SSH_DEPRECATED __attribute__ ((deprecated))

模块 A (错误模块)发出“已被执行”警告,提示错误。我以为我只看到一个错误的原因是 A 的编译标志包括-Werror。但是,两个模块都包含相同的标志。

但是,模块 B 有所不同。 A 包含来自 libssh.h arm-buidroot-linux-gnueabi,其中 B 包含该libssh.h和另一份{{1 }}(我认为第二个副本是libssh.h较旧版本的副本粘贴)。

我以为libssh.h不会出现在第二个SSH_DEPRECATED上,但是我错了,所以现在我不是什么原因了。

目前,我可以通过删除 A 中的 libssh.h 使其正常工作,但这很糟糕,因为:

  1. 我不知道根本原因是什么(即 B 中它是如何工作的)
  2. 我确实希望该标志[ -Werror ](可以通过添加 -Werror 然后返回 {{ 1}} ,但我不认为这是一个很好的解决方案。更像是hack)

我的问题 A 中的哪些内容会导致此已弃用的警告在 B 中不适用?

使用-Wno-deprecated

注意:我知道 deprecated Indicates that the name or entity declared with this attribute is deprecated, that is, the use is allowed, but discouraged for some reason.

0 个答案:

没有答案