c 编译器有一个函数卡在其命名空间中(也许?)。苹果

标签 c macos

一周前,我在代码中编写了一个名为 getline 的函数,但该函数不起作用。从那时起,每当我将函数命名为 getline 并尝试编译它时,它都不起作用。如果我将函数名称更改为其他名称,它会再次起作用。我已经重新启动了计算机(尽管实际上不需要这样做)。我怎样才能取回这个命名空间?

错误消息示例:

Numens-MBP:c examples mycotic$ cc testing.c
testing.c:9:5: error: conflicting types for 'getline'
int getline(void);
    ^
/usr/include/stdio.h:448:9: note: previous declaration is here
ssize_t getline(char ** __restrict __linep, size_t * __restrict __lineca...
        ^
testing.c:13:1: warning: type specifier missing, defaults to 'int'
      [-Wimplicit-int]
main()
^
testing.c:20:24: error: too few arguments to function call, expected 3, have 0
        while ((len = getline()) > 0)
                      ~~~~~~~ ^
/usr/include/stdio.h:448:1: note: 'getline' declared here
ssize_t getline(char ** __restrict __linep, size_t * __restrict __lineca...
^
testing.c:36:5: error: conflicting types for 'getline'
int getline(void)
    ^
/usr/include/stdio.h:448:9: note: previous declaration is here
ssize_t getline(char ** __restrict __linep, size_t * __restrict __lineca...
        ^
1 warning and 3 errors generated.

最佳答案

getline()是标准C 库函数。您的函数与标准库中的定义冲突。

为您的函数选择另一个名称。这张已拍摄。

关于c 编译器有一个函数卡在其命名空间中(也许?)。苹果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44610122/

相关文章:

C 编程 : Try to compile main class on terminal but it return me ./mainT

macos - Applescript 更改 osx 桌面(空格)不起作用

r - cronr 上的计划作业未运行,日志读取 '/bin/sh: Rscript: command not found'

c - 如何在 C 语言中跳过/忽略循环内的特定位置(列表上)?

c++ - 如何使用 C++ 创建 DRM 方案来保护 MP3 文件?

javascript - 将无类型数组编译为 C 的有效方法是什么?

c - 警告 : ‘noreturn’ function does return

mysql - 导入错误:没有名为 connector.conversion 的模块

ios - iOS系统下如何获取objective-c中的所有进程信息?

Git 和 Rails : ignore database. yml