This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Memory Specific Pointers

Hello,

I am delcaring some memory specific pointers using the examples on page 76 of the C51 Compiler Users Guide 01.97.

unsigned char xdata * idata key
Meaning a pointer in idata to a xdata unsigned char.

When I compile this I get a warning.
warning C258: 'key' mspace on parameter ignored
If I ignore this warning the code works fine, but I don't like ignoring warnings uless I understand the problem.

Does anyone know why this code generates a warning? I have searched through the Keil site but have had no success.

Thanks,
Nick

Parents
  • On page 94 of the 09.2001 Cx51 Compiler User's Guide it states:

    NOTE
    For compatibility with previous versions of the C51 compiler, you may specify the memory area before the data type. For example, the following declaration

    data char x; is equivalent to char data x;

    Nonetheless, this feature should not be used in new programs because it may not be supported in future versions of the Cx51 compiler.

    Be careful when you are using the old C51 syntax together with memory-specific pointers. In this case, the defintion:

    data char *x; is equivalent to char *data x;


    To my way of reading this, your definition unsigned char xdata * idata key just defined a pointer to an idata char and the pointer resides in xdata (try moving the * in front of key).

    I believe the old way is much clearer and should not even be considered for elimination. In the old declaration method you specify the memory area for the object then specify the object. Your variable "key" would be defined as:

    idata unsigned char xdata *key;

    Try specifying the variable type when it is an argument to a function. The old method allows you to cut the original definition, without the initial memory area, and paste it into the function definition. When I try this using the new format, I am forever getting confused.

Reply
  • On page 94 of the 09.2001 Cx51 Compiler User's Guide it states:

    NOTE
    For compatibility with previous versions of the C51 compiler, you may specify the memory area before the data type. For example, the following declaration

    data char x; is equivalent to char data x;

    Nonetheless, this feature should not be used in new programs because it may not be supported in future versions of the Cx51 compiler.

    Be careful when you are using the old C51 syntax together with memory-specific pointers. In this case, the defintion:

    data char *x; is equivalent to char *data x;


    To my way of reading this, your definition unsigned char xdata * idata key just defined a pointer to an idata char and the pointer resides in xdata (try moving the * in front of key).

    I believe the old way is much clearer and should not even be considered for elimination. In the old declaration method you specify the memory area for the object then specify the object. Your variable "key" would be defined as:

    idata unsigned char xdata *key;

    Try specifying the variable type when it is an argument to a function. The old method allows you to cut the original definition, without the initial memory area, and paste it into the function definition. When I try this using the new format, I am forever getting confused.

Children
  • Thanks Bob,

    I have just read that section now and it has cleared up a few other confusions for me.

    I think I have solved my original problem, as the warnings were generated when the pointer declaration was a parameter in a function declaration. Of course I shouldn't have specified the memory type of the pointer in the function declaration, just the memory type of what is being pointed to.

    Thanks again,
    Nick