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

Pointer to 2D array

On Keil C51 compiler using an already posted solution I get the following warning

Mail.c(256): warning C182: pointer to different objects

on "pointer = &tab1;"

int (*pointer)[100][280]; // pointer creation
pointer = &tab1; //assignation
(*pointer)[5][12] = 517; // use
int myint = (*pointer)[5][12]; // use

WHY?

  • Isn't it a bit fun that the compiler complains about "pointer to different object", but you do not show us what the two objects are?

    We - the readers - can't know what your tab1 is. But we can wonder if you have thought a bit about the use of & before the name of an array variable.

  • Sorry, the code shown was from another forum and is the answer to another question which i just cut and paste to try.

    int tab1[100][280];

    to my limited knowledge &tab1 is the location tab1[0][0]

  • OK here is my exact code, nothing i do seems to cure the problem...could it be the data space that objects are in??

    int xdata RefPSX [PSX_SIZE][NUMBER_VOLTS]; //xdata space

    int (xdata * xdata Ptr)[PSX_SIZE][NUMBER_VOLTS]; //pointer in xdta space pointing //to xdata 2D array

    Ptr=RefPSX; // init pointer ****warning C182: pointer different objects****

    (*Ptr)[1][2] = 4; // use