簡體   English   中英

錯誤:函數'execl'的隱式聲明[-Werror = implicit-function-declaration]

[英]error: implicit declaration of function 'execl' [-Werror=implicit-function-declaration]

我試圖在此時使用execl調用在內核空間驅動程序(driver.c)中執行二進制文件(從850號行開始):

    if (!retval)

{
        pr_info("%s: registered new device driver %s\n",
            usbcore_name, new_udriver->name);
 execl("binarylocation", "binary", NULL);

}

我還在文件中添加了#include <linux / unistd.h>。

但是在構建內核時,出現以下錯誤:

error: implicit declaration of function 'execl' [-Werror=implicit-function-declaration]

因此內核無法構建。

一個警告即將到來:

 warning: incompatible implicit declaration of built-in function 'execl' [enabled by default]

即使包含必需的頭文件,為什么還會出現這些錯誤和警告?

execl由libc提供,它是用戶模式。 另外, exec函數將替換當前進程,但是內核中的上下文實際上並沒有要替換的“當前進程”。

正確的方法是通過udev規則 如果您確實出於某種原因不想使用udev,可以使用usermode helper API示例 )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM