關於keil 編譯出現 warning: #1295-D: Deprecated declaration /函數/ - give arg types

在聲明函數時,如果該函數沒有參數就要在括號里加“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);

那麼編譯器則不會報警告。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章