We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
u8 Key; u8 VarItem; switch (Key) { case Kb_0 : ... case Kb_1 : ... case Kb_2 : ... case Kb_3 : ... case Kb_4 : ... case Kb_5 : ... case Kb_6 : ... case Kb_7 : ... case Kb_8 : ... case Kb_9 : ... case Kb_Min : ... case Kb_Enter : switch (VarItem) { case 0 : ... case 1 : ... case 2 : ... } }
When I compile above I got one warning warning: #516-D: transfer of control bypasses initialisation off: in the line near switch(VarItem). What is the meaning of this warning. When I ignore it, all works, but I do not like warnings ...
"I do not see any reason to generate a warning. The source code is a C++ file!"
Lots of C++ source files generate warnings! It's up to you to fix your source code!
void Test(u8 num) { switch (num) { case 1 : long test = 12; break; case 2 : break; } }
A warning seems absolutely in order here! in case 1, you both define and initialise 'test', but in case 2, you skip both the definition and the initialisation - what do you expect the compiler to make of this?!
The compiler warnings describes exactly what you are doing: "transfer of control" = the jump to case 2; "bypasses initialisation" - well, obviously the initialisation at case 1 is bypassed when the execution jumps straight to case 2, isn't it?!
Correct ! Shame on me ....
Luc