In my code I use the nop instruction (for short delay). The compiler warns me:
warning: #174-D: expression has no effect
How can I suppress this warning?
Are you using any compiler intrinsic for the nop or how do you insert it?
I insert it as following:
__NOP;
this is then defined in core_cmInstr.h as:
/** \brief No Operation No Operation does nothing. This instruction can be used for code alignment purposes. */ #define __NOP __nop
When I searched for "intrinsic" I found I can use __nop(). This did not give me any warnings.
Exactly. Note that when you inline assembler, then the compiler will run the code optimizer over your assembler instructions too. And the compiler see no use for any nop instructions. They are just good-for-nothing no-operations that should be removed - they are as meaningful as an assign a=a.
With the intrinsic, the compiler will be much nicer and caring about your NOP instructions, making it realize that you explicitly want the time delay side effect, and at that specific position in the code.