naseeam
asked on
How to initialize bitwise parameter ?
struct ParameterDef
{
....
/* bit 0 indicates if the parameter is special or not. It it's special read remaining bit(s)
to find the specialty. */
/* bit 0 - special 1, not special 0
bit 1 - map modbus register value to whole number
bits 2 - 15 - reserved for future use
*/
unsigned short special_param_bits;
}
There is array of above structure.
How to initialize special_param_bits variable with symbols instead of numbers ?
For special array entires, I want to indicate that the paramter is special and what specialty it has. i.e. SPECIAL & MAP_MODBUS_REG
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For correctness, jkr's suggestion of bitwise AND is actually incorrect. AND is for querying if a bit has been set; OR is used for setting the bit. In other words, 1 & 0 == 0 whereas 1 | 0 == 1.
*Argh*, it of course has to be 'OR', this is embarassing ;o)