【发布时间】:2020-04-25 15:12:48
【问题描述】:
我在16.04.1-Ubuntu LTS 上使用clang-7。
我收到此警告:
warning: implicit declaration of function 'getche' is invalid in C99
[-Wimplicit-function-declaration]
随后出现此错误:
error: undefined reference to 'getche'`
可能出了什么问题?
这是我的代码的链接:
【问题讨论】:
-
getche不是我知道的标准函数,您自己也没有定义。你想调用什么函数? -
getche是 Microsoft 特有的函数,在您的编译环境中不存在。 -
getche()获取用户输入的单个字符@DanielFarrell -
它是 Windows MSVC 中的一个扩展,需要
#include <conio.h>,但 MS 也弃用它以支持_getche(),以遵循标准 C 规则来实现特定于实现的名称。但是,该功能仍受支持。