- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
这不是关于如何解决出现在 C 程序中的“函数的隐式声明”警告的问题,这已经是 answered已经很多次了。
我知道这是一个编译器警告,我想知道为什么这是一个警告而不是错误?如果编译器看不到该函数,那么在运行时调用该函数时会发生什么?链接器是否最终解决了这个问题?或者我们是否假设调用产生此类警告的函数的行为是未知的?
最佳答案
why is this a warning rather than an error?
因为有很多遗留代码,所以以这种方式编写。编译器错误会破坏它。
If the compiler cannot see the function, what happens when the function is called at runtime? Does the linker ultimately resolve this issue?
让我们看例子:
int main()
{
foo();
return 0;
}
在工作时,编译器会生成自己的函数签名,如 int foo(...)
并将使用它。顺便说一句,它可能会导致非常奇怪的错误。所以目标文件会包含这个函数的调用就可以了。当你尝试链接它时,你会得到一个错误:undefined reference to `foo'。但是,如果您有另一个具有 foo
定义的模块,链接器将通过名称找到它并链接它。
Or are we to assume that the behaviour of calling a function that produced such warning is unknown?
正如我所说,它可能会导致一些奇怪的错误。想象一下,您有类似 int i = foo()
的代码,而 foo
没有签名。在另一个模块中,您有以下内容:int * foo(){...}
。在 64 位模式下构建应用程序时,您将仅将 64 位指针的 32 位放入 i
。所以你可能会说实际上你的程序的行为可能是未知的。
关于c - 为什么 "implicit declaration of function"只是一个警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38516758/
这是我的查询: INSERT INTO location_province(name, country) SELECT child.name ,location_country.id
尽管我看到 C++ 教程中广泛使用术语 implicit casting 来表示这样一个事实,即当您将某种类型分配给另一种类型时,类型的转换将自动(隐式)完成,但我经常听说应该叫implicit co
所有表格都在 utf_unicode_ci 中。 我这样做是为了检查 SELECT table_schema, table_name, column_name, character_set_name,
def MyFun(result: ListBuffer[(String, DateTime, List[(String, Int)])]): String = { val json = (r
我刚刚在 Postgres 中创建了一个表,并收到一条通知消息,我不完全理解隐式索引和序列。如有任何澄清,我们将不胜感激。 my_database=# CREATE TABLE sites my_da
我正在关注 Fernando Villalobos 的 React.js - A guide for Rails developers AirPair 教程。 这里的目标是使用 Rails 和 Rea
当我选择一个选项时,我有通过多选列表在 dbase 中搜索的代码我有这个错误: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (ut
我正在尝试使用 execl 调用来执行 kernel-space-driver (driver.c) 中的二进制文件此时(从第 850 行开始): if (!retval) {
我正在尝试在内核 3.13 上编译内核模块,但出现此错误: error: implicit declaration of function 'create_proc_read_entry' [-Wer
我检查了数据库表,发现它在 latin1_swedish_ci 中,所以我将其更改为 utf8_general_ci 然后我将排序规则从 latin1_swedish_ci 更改到所有字段的 utf8
尝试通过 MySQL 中的存储过程进行选择时出现以下错误 Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_ge
我收到了这个错误; Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT)
我需要您帮助确定为什么会出现此错误 Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT
我收到了这个错误; Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT)
MySql 上的错误信息: Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) fo
在我的删除服务器上执行 MySQL 中的存储过程时,如下所示: CREATE OR REPLACE PROCEDURE `SetNextPage`( IN `inRefNo` varchar(
我正在尝试为 Kali linux 2.0 安装我的 Alfa AWUS036ACH 适配器 我已经修复了之前的错误,但现在我被困在这里了。这是错误我正在接收。 os_dep/linux/rtw_an
我们正在使用以下存储过程,并且所有提到的表都使用“Collation = utf8_general_ci”,但我们仍然收到此错误: Error Code: 1267. Illegal mix of
我想让我的 User 表的 password 列在 mysql 中区分大小写。 表的说明如下: /*Table: mst_user*/ FIELD TYPE
我对这一切都很陌生,正在尝试在内核版本为 3.10.0-957.el7.x86_64 的虚拟机上编译程序。但我收到此错误: /home/../../../isr_demux.c: In functio
我是一名优秀的程序员,十分优秀!