Ttelmah
Joined: 11 Mar 2010 Posts: 19559
|
|
Posted: Tue Aug 20, 2013 8:33 am |
|
|
From K&R.
"The only legal operations on a structure are copying it, or assigning to it as a unit, taking it's address with &, or accessing it's members".
So it is legal to assign a number to it, or read a number directly from it, but not to treat it as a variable for maths. As such CCS is behaving 'bang on', in how it is treating it. When you simply read the number from it, an automatic cast is performed, and similarly when you write to it. However when you try to perform maths, it is still a structure, till the moment you perform the cast.
A remarkably 'spot on' behaviour from the compiler.
Personally I always prefer to be explicit, and use unions.
Best Wishes |
|