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

鄂曦之
2023-12-01

在声明函数时,如果该函数没有参数就要在括号里加“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);

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

 类似资料: