Home > Back-end > Do {} While (); Special usage? !!!!! Exp expression take twice than what's the point?
Do {} While (); Special usage? !!!!! Exp expression take twice than what's the point?
Time:12-31
See such a piece of code in opencv
# define CV_Assert (expr) do {the if (!!!!! (expr)); Else CV: : error (CV: : error: : StsAssert, # expr, CV_Func, __FILE__ and __LINE__); } while (0)
1, why do you want to use the do {} while () to wrap the code? What's the use? If it is in order to limit the scope, directly add {} do not?
2, if (!!!!! (expr)); This code what's the point? !!!!! Not equal to itself
Inside a lot of macro definition with judgment is like this, why?
CodePudding user response:
Bold code section is the same line, word wrap,,,,
CodePudding user response:
1. Direct use of {} there will be such problem If (exp) CV_Assert (expr) ; The else . Where else can't find the corresponding if Use the do {} while (0), there is no this problem
2.!!!!! Exp is not equal to itself such as exp itself is 2!! Exp result is 1
CodePudding user response:
Do () while {0}; Role is to let you no matter how a SAO operation can be as a whole,