Hi everyone,
Does anyone know if it is possible to supress a specific warning (arbitrary portion of code), as opposed to all warnings of a specific type?
For instance, I am porting code that uses assignments in conditions constantly, but consciously and on purpose. I would like to supress these warning for that code I have already verified, but not altogether, as this is just a part of a bigger project for which we would like to be warned about such situations.
Any pointers? I looked in the User Guide and Quick Reference, but could not find a straightforward answer.
Regards, George Andrew Brindeiro Robotron Automation and Technology
Another option is, of course, just to write:
a = b; if( a ) // or if( b ) { : }
It is a common mistake to assume that minimising source lines improves the efficiency of generated code!
user.it.uu.se/.../engblom-esc-sf-2001.pdf
"Trying to write your code on as few lines as possible, using ?:-expressions, postincrements, and comma expressions to squeeze in a lot of side effects in a single expression, will not make the compiler generate more efficient code. It will just make your source code convoluted and hard to maintain. It is easy to overlook a postincrement or an assignment if it is done in the middle of a complex expression. Write your code in a style that is easy to read."
www.iar.se/.../
Yes, complex source lines are seldom good. The maintainance costs are very much related to how easy the code is to read and understand.
But there can be a number of problems with rewriting an if statement to move out the assign. The assign may be a sub-expression where evaluation order is important.
The great thing about just adding (assign) != 0 is that it can be inlined without changing any evaluation order.
There is a bit of a difference between designing new code, and finding good code rewrite rules for existing code.