关于keil 编译出现 warning: #1295-D: Deprecated declaration /函数/ - give arg types

本文详细解析了在C语言中如何正确声明无参数函数以避免编译警告。通过对比不同声明方式,强调了使用void关键字的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在声明函数时,如果该函数没有参数就要在括号里加“void”

例如

函数定义

void LED_GPIO_Init()
{
        GPIO_InitTypeDef  GPIO_Init_Struct;
        GPIO_Init_Struct.GPIO_Pin    = LED_GPIO_PIN;
        GPIO_Init_Struct.GPIO_Mode   = GPIO_Mode_OUT;
        GPIO_Init_Struct.GPIO_OType  = GPIO_OType_PP;
        GPIO_Init_Struct.GPIO_OSpeed = GPIO_Speed_50MHZ;
        GPIO_Init_Struct.GPIO_PuPd   = GPIO_PuPd_Pu;
    
        GPIO_Init(LED_GPIO_Port ,&GPIO_Init_Struct);
}
声明函数时为

void LED_GPIO_Init();

编译之后就会出现

warning:  #1295-D: Deprecated declaration LED_GPIO_Init - give arg types

如果声明函数为

void LED_GPIO_Init(void);

那么编译器则不会报警告。

*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Rebuild target 'BUZZERWorking2' assembling startup_stm32f103xe.s... compiling main.c... ../Inc/main.h(57): warning: #1295-D: Deprecated declaration USER_UART_IRQHandler - give arg types void USER_UART_IRQHandler(); ../Src/main.c: 1 warning, 0 errors compiling gpio.c... ../Inc/main.h(57): warning: #1295-D: Deprecated declaration USER_UART_IRQHandler - give arg types void USER_UART_IRQHandler(); ../Src/gpio.c: 1 warning, 0 errors compiling stm32f1xx_hal_gpio_ex.c... compiling stm32f1xx_hal_tim.c... compiling stm32f1xx_hal_msp.c... ../Inc/main.h(57): warning: #1295-D: Deprecated declaration USER_UART_IRQHandler - give arg types void USER_UART_IRQHandler(); ../Src/stm32f1xx_hal_msp.c: 1 warning, 0 errors compiling stm32f1xx_it.c... ../Inc/main.h(57): warning: #1295-D: Deprecated declaration USER_UART_IRQHandler - give arg types void USER_UART_IRQHandler(); ../Src/stm32f1xx_it.c: 1 warning, 0 errors compiling stm32f1xx_hal_tim_ex.c... compiling stm32f1xx_hal.c... compiling stm32f1xx_hal_rcc_ex.c... compiling stm32f1xx_hal_rcc.c... compiling stm32f1xx_hal_cortex.c... compiling stm32f1xx_hal_dma.c... compiling stm32f1xx_hal_pwr.c... compiling stm32f1xx_hal_gpio.c... compiling stm32f1xx_hal_flash.c... compiling system_stm32f1xx.c... compiling stm32f1xx_hal_exti.c... compiling stm32f1xx_hal_flash_ex.c... linking... BUZZERWorking2\BUZZERWorking2.axf: Error: L6200E: Symbol MX_GPIO_Init multiply defined (by gpio.o and main.o). Not enough information to list image symbols. Not enough information to list load addresses in the image map. Finished: 2 information, 0 warning and 1 error messages. "BUZZERWorking2\BUZZERWorking2.axf" - 1 Error(s), 4 Warning(s). Target not created. Build Time Elapsed: 00:00:10
最新发布
07-05
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值