error: 'gets' undeclared here (not in a function)

出现问题

编译安装m4-1.4.16.tar.gz
wget http://ftp.gnu.org/gnu/m4/m4-1.4.16.tar.gz
tar xvf m4-1.4.16.tar.gz
./configure
make

报错提示:error: 'gets' undeclared here (not in a function)

解决办法:

[root@localhost m4-1.4.16]# vi lib/stdio.in.h
查找字段:gets is a security hole
注释
将_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 字段和他之前的注释 /* 一块注释掉,如下

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

再添加如下内容:

#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

猜你喜欢

转载自blog.51cto.com/5065548971213/2114389