c - C 中函数 ‘getChar’ 的隐式声明

标签 c compiler-construction compiler-errors

有些人在尝试用 C 编译程序时出现此错误。

myfunctions.c:27:2: warning: implicit declaration of function ‘getChar’ [-Wimplicit-function-declaration]

这是第 27 行:

while(myChar = getChar() && myChar != '')

我在标题中调用它:

#include <stdio.h>
#include <unistd.h>

最佳答案

拼写为getchar,而不是getChar。 C 区分大小写,几乎所有标准 C 函数的名称都是小写的。

至于为什么当它不存在时它被“隐式声明”......在旧版本的 C 中,如果编译器不知道函数名称,则假定它是一个返回 的函数整数。这几乎就像您说的是 int getChar();。我听说 C99 不允许这样做,但大多数编译器无论如何都不会坚持这样做,除非你告诉他们这样做。

关于c - C 中函数 ‘getChar’ 的隐式声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9106769/

相关文章:

html - 如何使用 C 将 HTML 解析为 .txt 格式

c# - 使用 ANTLR : Compilation Unit 构建自己的 C# 编译器

swift - 来自 https 请求的奇怪 MLFeatureValue 响应

c# - 命令行 MSBuild 无法编译代码

c++ - OpenSSL 编译在测试中失败

c - 使用 libgps 未接收任何 GPS 数据

c - 小端结果

c - 处理嵌套结构访问

java - 如何调用 super 方法(即 : toString()) from outside a derived class

java - Java Applet允许Javac或其他jar访问吗?