centos7编译libiconv报错:./stdio.h:1010:1: error: 'gets' undeclared here (not in a function)

如题:配置编译参数通过,在进行 make 的时候报如下错误:

  1. In file included from progname.c:26:0:
  2. ./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function)
  3. _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
  4. ^
  5. make[2]: *** [progname.o] Error 1
  6. make[2]: Leaving directory `/usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib'
  7. make[1]: *** [all] Error 2
  8. make[1]: Leaving directory `/usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib'
  9. make: *** [all] Error 2
复制代码


解决方法:

使用 find 查找 stion.in.h 文件:

 find / -name 'stdio.in.h'

复制代码

编辑该文件

 vim /usr/local/src/zabbix-2.4.7/libiconv-1.14/srclib/stdio.in.h

复制代码

通过关键字 gets 找到698 行,将其和695行一同注释:

  1. 695 /* It is very rare that the developer ever has full control of stdin,
  2. 696    so any use of gets warrants an unconditional warning.  Assume it is
  3. 697    always declared, since it is required by C89.
  4. 698 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");*/
复制代码

然后再注释的行下面添加以下三行:

  1. #if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
  2. _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
  3. #endif
复制代码

保存退出!(注意#endif 下面还有一个 #endif):

#配置文件内容(如下)

#endif
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif

重新编译即可!

转载于:https://www.cnblogs.com/A121/p/10342226.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值