warning:function "bsp_read_word" declared implicitly错误原因

该博客主要介绍了在C语言编程中遇到的'warning: function declared implicitly'警告的原因及解决方法。问题源于没有在调用函数前声明函数原型。通过在相关头文件中添加extern关键字声明函数,并确保正确包含头文件,可以消除此警告。在文中,博主以delay()函数为例,说明了解决该问题的具体步骤。
这是由于没有声明函数原型造成的。
在a.c中,
void main()
{
.....
delay();
....
}
在b.c中
void delay()
{
}
如果就只是这样的话,就会出现上面的worning的。
解决办法是在b.h中写 extern void delay();然后在a.c中include "b.h"就ok了。
再看程序,发现只包含了DSP281x_Device.h,后来把DSP281x_Examples.h添加进去就消除worning了。
DSP281x_Examples.h中又include“DSP281x_GlobalPrototypes.h”,而这个头文件中声明了全部的外部函数
*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Build target 'Target 1' compiling i2c.c... i2c.h(6): error: #147-D: declaration is incompatible with "void I2C_Init(I2C_TypeDef *, I2C_InitTypeDef *)" (declared at line 535 of ".\Library\stm32f10x_i2c.h") void I2C_Init(void); i2c.h(15): warning: #1-D: last line of file ends without a newline #endif i2c.c(20): warning: #223-D: function "SDA_OUT" declared implicitly SDA_OUT(); i2c.c(21): warning: #223-D: function "I2C_SDA_H" declared implicitly I2C_SDA_H(); i2c.c(22): warning: #223-D: function "I2C_SCL_H" declared implicitly I2C_SCL_H(); i2c.c(24): warning: #223-D: function "I2C_SDA_L" declared implicitly I2C_SDA_L(); i2c.c(26): warning: #223-D: function "I2C_SCL_L" declared implicitly I2C_SCL_L(); i2c.c(31): warning: #223-D: function "SDA_OUT" declared implicitly SDA_OUT(); i2c.c(32): warning: #223-D: function "I2C_SCL_L" declared implicitly I2C_SCL_L(); i2c.c(33): warning: #223-D: function "I2C_SDA_L" declared implicitly I2C_SDA_L(); i2c.c(35): warning: #223-D: function "I2C_SCL_H" declared implicitly I2C_SCL_H(); i2c.c(36): warning: #223-D: function "I2C_SDA_H" declared implicitly I2C_SDA_H(); i2c.c(43): warning: #223-D: function "SDA_OUT" declared implicitly SDA_OUT(); i2c.c(44): warning: #223-D: function "I2C_SCL_L" declared implicitly I2C_SCL_L(); i2c.c(46): warning: #223-D: function "I2C_SDA_H" declared implicitly if((txd & 0x80) >> 7) I2C_SDA_H(); i2c.c(47): warning: #223-D: function "I2C_SDA_L" declared implicitly else I2C_SDA_L(); i2c.c(50): warning: #223-D: function "I2C_SCL_H" declared implicitly I2C_SCL_H(); i2c.c(60): warning: #223-D: function "SDA_IN" declared implicitly SDA_IN(); i2c.c(62): warning: #223-D: function "I2C_SCL_L" declared implicitly I2C_SCL_L(); i2c.c(64): warning: #223-D: function "I2C_SCL_H" declared implicitly I2C_SCL_H(); i2c.c(66): error: #20: identifier "READ_SDA" is undefined if(READ_SDA) receive++; i2c.c(77): warning: #223-D: function "SDA_IN" declared implicitly SDA_IN(); i2c.c(78): warning: #223-D: function "I2C_SDA_H" declared implicitly I2C_SDA_H(); Delay_us(1); i2c.c(79): warning: #223-D: function "I2C_SCL_H" declared implicitly I2C_SCL_H(); Delay_us(5); i2c.c(80): error: #20: identifier "READ_SDA" is undefined while(READ_SDA) { i2c.c(87): warning: #223-D: function "I2C_SCL_L" declared implicitly I2C_SCL_L(); i2c.c(93): warning: #223-D: function "I2C_SCL_L" declared implicitly I2C_SCL_L(); i2c.c(94): warning: #223-D: function "SDA_OUT" declared implicitly SDA_OUT(); i2c.c(95): warning: #223-D: function "I2C_SDA_L" declared implicitly I2C_SDA_L(); i2c.c(97): warning: #223-D: function "I2C_SCL_H" declared implicitly I2C_SCL_H(); i2c.c(104): warning: #223-D: function "I2C_SCL_L" declared implicitly I2C_SCL_L(); i2c.c(105): warning: #223-D: function "SDA_OUT" declared implicitly SDA_OUT(); i2c.c(106): warning: #223-D: function "I2C_SDA_H" declared implicitly I2C_SDA_H(); i2c.c(108): warning: #223-D: function "I2C_SCL_H" declared implicitly I2C_SCL_H(); i2c.c(120): warning: #1-D: last line of file ends without a newline #define READ_SDA (GPIOB->IDR & GPIO_Pin_7) i2c.c: 32 warnings, 3 errors compiling main.c... User\main.c(6): error: #5: cannot open source input file "mpu6050.h": No such file or directory #include "mpu6050.h" // 鏇挎崲jy61p.h涓篗PU6050椹卞姩 User\main.c: 0 warnings, 1 error compiling mpu6050.c... mpu6050.h(21): warning: #1-D: last line of file ends without a newline #endif i2c.h(6): error: #147-D: declaration is incompatible with "void I2C_Init(I2C_TypeDef *, I2C_InitTypeDef *)" (declared at line 535 of ".\Library\stm32f10x_i2c.h") void I2C_Init(void); i2c.h(15): warning: #1-D: last line of file ends without a newline #endif mpu6050.c(69): warning: #1-D: last line of file ends without a newline } mpu6050.c: 3 warnings, 1 error ".\Objects\Project.axf" - 5 Error(s), 35 Warning(s). Target not created. Build Time Elapsed: 00:00:01
最新发布
07-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kobesdu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值