SyntaxError: missing formal parameter[详细了解]

本文讲解了JavaScript中常见的函数定义错误,特别是使用var关键字作为参数名称的问题,指出正确的函数定义方式,并强调代码规范的重要性。

错误区域代码


 错误原因

js所有的类型都用var表示,因此不用var id 直接 id就可以了,

报错信息的意思就是书写不规范,不正规

function getpass(var id){    正确的是 function getpass(id){


 

#include "motor_control.h" #include "headfile.h" static uint8_t duty; void motor_init(void) { // 初始化PWM频率为50Hz,占空比初始值 pwm_init(PWMB_CH4_P77, 50, 600); pwm_init(PWMB_CH1_P74, 50, 600); pwm_init(PWMA_CH3P_P64, 50, 600); pwm_init(PWMA_CH1P_P60, 50, 600); } void motor_set_duty(uint8_t duty) { // 设置电机占空比 pwm_duty(PWMB_CH4_P77, duty); pwm_duty(PWMB_CH1_P74, duty); pwm_duty(PWMA_CH3P_P64, duty); pwm_duty(PWMA_CH1P_P60, duty); }Build target 'STC32G12K128' compiling main.c... ..\USER\src\main.c(36): warning C140: 'motor_init' undefined; assuming 'extern int motor_init()' ..\USER\src\main.c(43): error C25: syntax error near 'motor_duty' ..\USER\src\main.c(46): warning C140: 'motor_set_duty' undefined; assuming 'extern int motor_set_duty()' ..\USER\src\main.c(46): warning C95: 'motor_set_duty': too many actual parameters ..\USER\src\main.c(49): error C316: unterminated conditionals ..\USER\src\main.c(49): error C25: syntax error near '<EOF>' ..\USER\src\main.c(49): error C7: compilation aborted compiling motor_control.c... ..\CODE\motor_control.c(3): warning C34: 'duty': missing declaration specifiers ..\CODE\motor_control.c(3): error C42: 'duty': not in formal parameter list ..\CODE\motor_control.c(5): error C42: 'motor_init': not in formal parameter list ..\CODE\motor_control.c(5): error C25: syntax error near '{' ..\CODE\motor_control.c(20): error C316: unterminated conditionals ..\CODE\motor_control.c(20): error C7: compilation aborted Target not created. Build Time Elapsed: 00:00:00
07-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

qq_37591637

请给我持续更新的动力~~

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

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

打赏作者

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

抵扣说明:

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

余额充值