Skip to main content
MikeDB
Senior II
May 9, 2019 2:38 PM UTC
Solved

Is it possible to mute a particular warning in the STM32CubeIDE compiler ?

I had to create some register variables and inline assembler to enforce use of the M7's SMLAL instruction and now keep getting the warning several times per compile :

warning: optimization may eliminate reads and/or writes to register variables [-Wvolatile-register-var]

Is it possible to mute just this particular warning ? I went to the Files->Properties->Warnings page and there are various tickboxes but I can't see a way to mute a particular warning.

This topic has been closed for replies.
After Forever
After ForeverBest answer
Senior III
May 9, 2019 2:48 PM UTC

Is there a place in the Settings to add a custom compiler option? Just adding "-Wno-volatile-register-var" there should do the work.

Or, you could temporarily disable the warning only for those lines you want:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wvolatile-register-var"
/* code generating the warning */
#pragma GCC diagnostic pop

3 replies

After Forever
After ForeverBest answer
Senior III
May 9, 2019 2:48 PM UTC

Is there a place in the Settings to add a custom compiler option? Just adding "-Wno-volatile-register-var" there should do the work.

Or, you could temporarily disable the warning only for those lines you want:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wvolatile-register-var"
/* code generating the warning */
#pragma GCC diagnostic pop

MikeDB
MikeDBAuthor
Senior II
May 9, 2019 6:46 PM UTC

Thanks - I hadn't thought of using a pragma. I can see the real warnings now.

MikeDB
MikeDBAuthor
Senior II
May 9, 2019 2:56 PM UTC

It seems to just be tickboxes. The only field that looks where it looks like it should go is in the Settings->GCC Compiler->Tool Settings but this field is greyed out and so not editable, presumably to stop people making silly mistakes.