[英]conflicting types for getline function
我的代码块中有一个getline函数的函数,但是在编译make文件时出现以下错误:
cc -DMAIN -c -o terp.o terp.c
terp.c:130:15: error: conflicting types for ‘getline’
In file included from terp.c:2:0:
/usr/include/stdio.h:675:20: note: previous declaration of ‘getline’ was here
make: *** [terp.o] Error 1
terp.c部分在130左右:
PRIVATE char *getline()
{
static int first_time_called=1;
if(!first_time_called)
return 0;
first_time_called=0;
return Expr;
}
至少有三种可能的解决方案。
由于getline()
不在标准c库中,而是在POSIX(和GLIBC)中,因此可以进行开关以禁用其扩展名(它们在GCC中默认启用)。 尝试使用命令cc -DMAIN -std=c99 -c -o terp.o terp.c
编译源代码。
如果需要POSIX扩展,则必须将getline()
函数重命名为其他名称。
从您的源中删除#include <stdio.h>
,此错误消息将消失。 但是,如果在源代码中使用POSIX的getline()
您可能会感到困惑,因为它将被您的源代码代替。
您需要为getline
函数选择一个不同的名称,因为标准clib中已经有一个getline
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.