I have 3 file dependencies, in one of them I have implemented one function that you can see the first of all below. It returns an int type of 32 bits. The second file implements a function that calls the funtion of the first file. This function will be called from main file (third file). When I compile (with keil IDE) all the files I have the following warning msg:
compiling App_Task_CAN.c...
..\src\Application_Tasks\App_Task_CAN.h(132): warning: #1295-D: Deprecated declaration App_Task_CAN_GetError - give arg types
uint32_t App_Task_CAN_GetError();
This is a part of code in a file I have included stm32l4xx_hal_can.c:
uint32_t HAL_CAN_GetError(CAN_HandleTypeDef *hcan)
{
return hcan->ErrorCode;
}
where hcan is in stm32l4xx_hal_can.h a type of:
/**
* @brief CAN handle Structure definition
*/
typedef struct
{
CAN_TypeDef *Instance; /*!< Register base address */
CAN_InitTypeDef Init; /*!< CAN required parameters */
CanTxMsgTypeDef* pTxMsg; /*!< Pointer to transmit structure */
CanRxMsgTypeDef* pRxMsg; /*!< Pointer to reception structure */
__IO HAL_CAN_StateTypeDef State; /*!< CAN communication state */
HAL_LockTypeDef Lock; /*!< CAN locking object */
__IO uint32_t ErrorCode; /*!< CAN Error code */
}CAN_HandleTypeDef;
Furthermore I have this implementation in other file calling to the first shown function in App_Task_CAN.c :
...
CAN_HandleTypeDef HCAN_Struct;//hcan struct type declaration in this file
uint32_t App_Task_CAN_GetError()
{
static uint32_t ErrorNumb;
ErrorNumb=HAL_CAN_GetError(&HCAN_Struct);
return ErrorNumb; //I want this functions returns an int value.
}
Main code in main.c:
int main(void)
{
uint32_t ErrorType=0;
while (1)
{
ErrorType=App_Task_CAN_GetError(); //it takes the resulting value of calling HAL_CAN_GetError(&HCAN_Struct)
}
}
The warning disappears when I pass an argument. But I don't know why it is asking me for a argument for saving the return value.
Why does it needs an argument since it returns an uint32_t? Is it possible to improve the code in order to get updated ErrorType from main when main calls App_Task_CAN_GetError()?
Note: stm32l4xx_hal_can.c and .h can not been modified since they are system libraries files.