Hi there,
I have been programming using DC 8.51 on RCM 3100 for some time. I usually hardcode the values for #defines. I was trying to do bitwise operation for #define e.g. #define SESSION_B SESSION_A | SESSION_ONLINE. When SESSION_B is compared to any value, it always yields TRUE (see sample code below).
Does DC not support this operation? or does it do some implicit conversion? or did I do anything wrong?
////////////////////////////////////////////////////////////
/*** Beginheader */
#define SESSION_OFFLINE 0
#define SESSION_ONLINE 1
#define SESSION_A 2
#define SESSION_B SESSION_A | SESSION_ONLINE
/*** endheader */
/*** BeginHeader main /
xmem void main( void );
/** endheader */
xmem void main()
{
int i;
// SESSION_B is 3
for( i = 0; i < 10; i++ )
{
if( i == SESSION_B )
printf("TRUE i = %d, SESSION_B = %d
", i, SESSION_B );
else
printf(“FALSE”);
}
}
//////////////////////////////////////////////////////////
The results were:
TRUE i = 0, SESSION_B = 3
TRUE i = 1, SESSION_B = 3
TRUE i = 2, SESSION_B = 3
TRUE i = 3, SESSION_B = 3
TRUE i = 4, SESSION_B = 3
TRUE i = 5, SESSION_B = 3
TRUE i = 6, SESSION_B = 3
TRUE i = 7, SESSION_B = 3
TRUE i = 8, SESSION_B = 3
TRUE i = 9, SESSION_B = 3
TIA,
Andy