这是我的代码(简化版):
#include <stdio.h>
#include <string.h>
#define SIZE 240
int main(void)
{
char word[SIZE];
gets(word);
return 0;
}
为什么 GCC 给我
№3.c:在函数“main”中:
№3.c:13:2:警告:函数‘gets’的隐式声明[-Wimplicit-function-declaration]
这个警告?
GCC 版本是 5.2.1
P.S.该程序正在运行。
附言我永远不会用gets(),我永远不会用gets(),我永远不会用gets(),我永远不会用gets()
最佳答案
函数gets
C 标准不再支持它,因为它是一个不安全的函数。所以函数声明似乎被排除在标题<stdio.h>
之外现在编译器不知道 gets
的声明是什么.
来自 C 标准(前言)
6 This third edition cancels and replaces the second edition, ISO/IEC 9899:1999, as corrected by ISO/IEC 9899:1999/Cor 1:2001, ISO/IEC 9899:1999/Cor 2:2004, and ISO/IEC 9899:1999/Cor 3:2007. Major changes from the previous edition include:
...
— removed the gets function (<stdio.h>)
关于c - 为什么 gcc 提示 gets(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35358767/