cancel
Showing results for 
Search instead for 
Did you mean: 

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

MikeDB
Lead

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

3 REPLIES 3

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
Lead

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.

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