Hi c51'wizards
What is the difference in having a variable as:
xdata unsigned char var;
versus:
unsigned char xdata var; ??????
Does it make sense to have a variable as:
xdata unsigned char xdata var; ?????
Please be easy in your answers, since I am a novice in this matter.
Thanks in advanced,
DB
This is standard C syntax. Consider the use of the const qualifier.
One way to look at it is that const is left-associative. That is, it applies to the thing to its left. The exception is of course when const is the first thing in the declaration; there's nothing to the left, and it's forced to apply to the thing to its right.
// equivalent declarations const U8 foo; // const U8 U8 const foo; // const U8
// with pointers const U8* foo; // pointer to const U8 U8 const* foo; // pointer to const U8 U8* const foo; /// const pointer to variable U8
(I happen to prefer the C++ style of putting the pointer with the type, rather than the name. The K&R style "U8 *foo, *bar" is usually justified as "making the * part of the variable name", so that *foo is an integer. Also, because of just this case of multiple declarations on one line. But then, confusing and error-prone syntax means that that's poor style to start with. Put the * with the type and not with the variable, and it helps make the syntax of complex pointer declarations more clear. "foo" is a "pointer to U8", rather than "*foo" is a "U8" -- oh, wait, *foo is a funny name.)
The other way to look at it is to imagine a vertical line drawn through the "*" in the pointer declaration. Any qualifier to the left of this line applies to the thing pointed to. Any qualifer to the right of this line applies to the pointer itself.
Keil's mspace qualifers should follow the same syntactic rules. I seem to recall I ran across a case where you couldn't use an mspace qualifer where I thought I might. But I haven't run across a case where the qualifers give different results than const.
True, but I still think it'd be helpful if Keil stated it explicitly