[C/C++] make constant to be l-value.

Language/C&C++ 2006.07.06 23:57
[[ blog 이사 과정에서 정확한 posting날짜가 분실됨. 년도와 분기 정도는 맞지 않을까? ]]

When compare values, try to put constant or returned value from function call into left side - make it as l-value.
This habit can prevent you from mistake - using '=' instead of '=='.
(Compiler can detect this error(mistake)!)

#define X_VAL (100)
...
if( a == X_VAL ) { ... } // This is not good!
if( X_VAL == a) { ... } // Better
tags :
Trackbacks 0 : Comments 0