implicit declaration of function 這種警告問題的原因及解決方案

來源:互聯網
上載者:User

最近在改進SD卡的SEP4020驅動時,在改掉所有的warning時老報一個implicit declaration of function 的警告錯誤,上網查了下原因,原來有兩種情況會產生這種情況

1  沒有把函數所在的c檔案產生.o目標檔案
2  在函數所在的c檔案中定義了,但是沒有在與之相關聯的.h檔案中聲明

[root@mail linux]# make
  CHK     include/linux/version.h
make[1]: “include/asm-arm/mach-types.h”是最新的。
  CHK     include/linux/compile.h
  CHK     usr/initramfs_list
  CC      drivers/mmc/sep_mci.o
drivers/mmc/sep_mci.c: In function `sep4020sdi_probe':
drivers/mmc/sep_mci.c:745: warning: implicit declaration of function `clk_get'
drivers/mmc/sep_mci.c:745: warning: assignment makes pointer from integer without a cast
drivers/mmc/sep_mci.c:754: warning: implicit declaration of function `clk_enable'
drivers/mmc/sep_mci.c:800: warning: implicit declaration of function `clk_put'
drivers/mmc/sep_mci.c: In function `sep4020sdi_remove':
drivers/mmc/sep_mci.c:830: warning: implicit declaration of function `clk_disable'
drivers/mmc/sep_mci.c: In function `sep4020sdi_irq':
drivers/mmc/sep_mci.c:197: warning: 'sdi_cclear' might be used uninitialized in this function
drivers/mmc/sep_mci.c: In function `sep4020sdi_probe':
drivers/mmc/sep_mci.c:673: warning: 'host' might be used uninitialized in this function
drivers/mmc/sep_mci.c: At top level:
drivers/mmc/sep_mci.c:337: warning: 'sep4020sdi_irq_cd' defined but not used
  LD      drivers/mmc/built-in.o
  LD      drivers/built-in.o
  GEN     .version
  CHK     include/linux/compile.h
  UPD     include/linux/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
  KSYM    .tmp_kallsyms1.S
  AS      .tmp_kallsyms1.o
  LD      .tmp_vmlinux2
  KSYM    .tmp_kallsyms2.S
  AS      .tmp_kallsyms2.o
  LD      vmlinux
  SYSMAP  System.map
  SYSMAP  .tmp_System.map
  OBJCOPY arch/arm/boot/Image
  Kernel: arch/arm/boot/Image is ready
  GZIP    arch/arm/boot/compressed/piggy.gz
  AS      arch/arm/boot/compressed/piggy.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready
  Building modules, stage 2.
  MODPOST
於是我在sep_mci.c的頭部將 <linux/clk.h>包含進去就行了

這樣就沒有任何warning產生了,呵呵

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.