libiconv-1.14 error: ‘gets’ undeclared here (not in a function)

来源:互联网 发布:只有我知双语未删减版 编辑:程序博客网 时间:2024/06/05 15:46

centos7下编译安装libiconv-1.14报错,信息如下:

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

解决方法:
编辑 libiconv-1.14/srclib/stdio.h 文件,这个文件在make之后才会生成,源码中是没有的。

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

第1010行,把 _GL_WARN_ON_USE (gets, “gets is a security hole – use fgets instead”); 外面加一个if,
改为:

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


继续make && make install 通过

原创文章,转载请注明。本文链接地址: http://www.rootop.org/pages/3532.html

阅读全文
0 0