2020.9.6 · main.c(23): error: #165: too few arguments in function call

本文探讨了在C编程中,当源文件中定义的函数带有参数,但在实际调用时未传递参数的问题。提供了两种解决方案:一是修改函数定义去除参数;二是确保调用时正确传递参数。

添加头文件后

源.c文件中函数有参数

但是实际调用时没有。

方法一:源.c文件中的函数不要有参数
方法二:调用函数时把参数写上。

#include "ti_msp_dl_config.h" // 灰度传感器引脚定义 #define GRAY_SENSOR_PORT GPIOB #define GRAY_SENSOR_PINS (GPIO_IRST_PIN_0_PIN | GPIO_IRST_PIN_1_PIN | GPIO_IRST_PIN_2_PIN | GPIO_IRST_PIN_3_PIN | GPIO_IRST_PIN_4_PIN | GPIO_IRST_PIN_5_PIN | GPIO_IRST_PIN_6_PIN| GPIO_IRST_PIN_7_PIN) // 传感器读取延时(微秒) #define SENSOR_READ_DELAY 100 void read_gray_sensors(uint8_t *sensor_data) { /* 读取8个传感器状态并打包为字节 */ uint32_t pin_values = DL_GPIO_readPins(GRAY_SENSOR_PORT); *sensor_data = (uint8_t)((pin_values >> 0) & 0xFF); // 提取PA0-PA7状态 } void send_sensor_data(uint8_t data) { /* 通过UART发送传感器数据 */ DL_UART_Main_fillTXFIFO(UART_0_INST, &data, 1); while (!DL_UART_Main_isTXFIFOEmpty(UART_0_INST)); // 等待发送完成 } int main(void) { // 系统初始化 SYSCFG_DL_init(); // 主循环 while (1) { uint8_t sensor_data; // 1. 读取传感器数据 read_gray_sensors(&sensor_data); // 2. 通过UART发送数据 send_sensor_data(sensor_data); } } [0]**** Build of configuration Debug for project empty_LP_MSPM0G3507_nortos_ticlang **** [1]"C:\\ti\\ccs2020\\ccs\\utils\\bin\\gmake" -k -j 12 all -O [2]Building file: "../empty.c" [3]Invoking: Arm Compiler [4]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O2 -I"C:/Users/86147/workspace_ccstheia/empty_LP_MSPM0G3507_nortos_ticlang" -I"C:/Users/86147/workspace_ccstheia/empty_LP_MSPM0G3507_nortos_ticlang/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -gdwarf-3 -MMD -MP -MF"empty.d_raw" -MT"empty.o" @"./device.opt" -o"empty.o" "../empty.c" [5]../empty.c:44:60: error: too few arguments to function call, expected 2, have 1 [6] 44 | uint32_t pin_values = DL_GPIO_readPins(GRAY_SENSOR_PORT); [7] | ~~~~~~~~~~~~~~~~ ^ [8]C:/ti/mspm0_sdk_2_05_01_00/source\ti/driverlib/dl_gpio.h:2227:26: note: 'DL_GPIO_readPins' declared here [9] 2227 | __STATIC_INLINE uint32_t DL_GPIO_readPins(GPIO_Regs* gpio, uint32_t pins) [10] | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [11]1 error generated. [12]gmake: *** [subdir_rules.mk:11: empty.o] Error 1 [13]gmake: Target 'all' not remade because of errors. [14]**** Build Finished **** 解决上面代码的这个报错问题
07-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

追逐者-桥

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

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

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

打赏作者

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

抵扣说明:

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

余额充值