Disable a specific warning with ARM GCC

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
user_1669321
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Hi,

I'd like to disable a single warning that I get in a header file. I have trouble finding it in the GCC documentation. Is there a way to do it?

I'm using the Protothread library, and I get a warning in one of the header files (pt.h). Here's the warning:

"variable 'PT_YIELD_FLAG' set but not used [-Wunused-but-set-variable]"

Thanks,

Fred

0 Likes
1 Solution
user_1669321
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

I just found it by googling the error.

I needed to add __attribute__ ((unused)) to the declaration of the variable.

So the line

#define PT_BEGIN(pt) { char PT_YIELD_FLAG = 1; LC_RESUME((pt)->lc)

became

#define PT_BEGIN(pt) { char __attribute__ ((unused)) PT_YIELD_FLAG = 1; LC_RESUME((pt)->lc)

View solution in original post

0 Likes
1 Reply
user_1669321
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

I just found it by googling the error.

I needed to add __attribute__ ((unused)) to the declaration of the variable.

So the line

#define PT_BEGIN(pt) { char PT_YIELD_FLAG = 1; LC_RESUME((pt)->lc)

became

#define PT_BEGIN(pt) { char __attribute__ ((unused)) PT_YIELD_FLAG = 1; LC_RESUME((pt)->lc)

0 Likes