2017-05-02 04:36 PM
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!
#warnings #attrib_unusedSolved! Go to Solution.
2017-05-04 02:47 AM
No. Don't add compiler specific attributes. Use this instead:
int foo(int unused){
(void)unused;
}�?�?�?�?�?�?
Or just suppress the warning. This you can to with #pragma per file, per compiler.
2017-05-03 01:48 AM
Hi,
Thank you for your suggestion to improve our solutions.
I will share this internally for further investigation and keep you informed about the taken actions/explanation if needed.
ThanksImen
2017-05-04 02:47 AM
No. Don't add compiler specific attributes. Use this instead:
int foo(int unused){
(void)unused;
}�?�?�?�?�?�?
Or just suppress the warning. This you can to with #pragma per file, per compiler.
2017-05-04 03:11 PM
even better!
edit: although with that solution I'm now getting 'statement has no effect [-Wunused-value]' warnings ...
2017-05-05 08:46 AM
You have waaay to much warnings enabled. This is not default behavior.