AnsweredAssumed Answered

[Suggestion] add __attribute__((unused)) to unused parameters in all library functions

Question asked by Valentin on May 3, 2017
Latest reply on May 5, 2017 by Jeroen3

When compiling projects using standard HAL libraries, I often get a dozen or so warnings about unused parameters in library functions.

Would it be possible to tell your programmers to please add "__attribute__((unused))" in front of all unused parameters or unused variables in general?

 

Right now my only solution is to completely disable all warnings for the "Middlewares" and "Drivers" folders which is not really helpful.

 

Examples:

usbd_desc.c:

uint8_t *  USBD_HS_ManufacturerStrDescriptor(__attribute__((unused)) USBD_SpeedTypeDef speed , uint16_t *length)
{
  USBD_GetString ((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
  return USBD_StrDesc;
}
uint8_t *  USBD_HS_LangIDStrDescriptor( __attribute__((unused)) USBD_SpeedTypeDef speed , uint16_t *length)
{
  *length =  sizeof(USBD_LangIDDesc); 
  return USBD_LangIDDesc;
}

 

Compiling a sample project with some extra warning flags enabled should give a very quick & easy way to find all relevant lines.

 

Thank you!

Outcomes