incompatible pointer types error

Working on a program that has some delarations like:

int AFT_PORT_POSITION[] = {500,500+39,113,113+21};

const char Aft[] = {

92,0,5,8,35,0,6,8,10,0,3,8,24,0,3,8,9,0,4,8,17,0,3,8,5,0,3,8,8,0,4,8,17,0,3,8,5,0,3,8,7,0,

6,8,16,0,3,8,5,0,3,8,7,0,6,8,13,0,16,8,5,0,2,8,2,0,2,8,13,0,16,8,4,0,3,8,2,0,3,8,15,0,3,8,

5,0,3,8,6,0,3,8,2,0,3,8,15,0,3,8,5,0,3,8,5,0,3,8,4,0,3,8,14,0,3,8,5,0,3,8,5,0,10,8,14,0,

3,8,5,0,3,8,5,0,10,8,14,0,3,8,5,0,3,8,4,0,3,8,6,0,3,8,13,0,3,8,5,0,3,8,4,0,3,8,6,0,3,8,

13,0,3,8,5,0,3,8,3,0,3,8,8,0,3,8,8,0,6,8,6,0,3,8,3,0,3,8,8,0,3,8,8,0,5,8,7,0,3,8,3,0,

3,8,8,0,3,8,124,0,255,255

};

In the program I have

void Main_Screen_Buttons(void)

{

  int *size;

const char _far *name;

size = &AFT_STRBRD_POSITION;

Display_Graphic_Position(size);

name = &Aft;

Display_Graphic(name);

}

I am getting the incompatible pointer types error on both the

size = &AFT_STRBRD_POSITION;

and the

name = &Aft;

lines.  size is declared to be a int pointer and AFT_PORT_POSITION is an int array.

name is declared to be a const char just as Aft is a const char array.

So why the error?

Thanks,

David

  • Answer Found - by removing the & from each of the two statements the program still works without the warnings

    size = AFT_STRBRD_POSITION;   //removed &

    Display_Graphic_Position(size);

    name = Aft;                                   //removed  &

    Display_Graphic(name);

    David

  • This is C convention.  The array names Aft and AFT_STRBRD_POSITION are pointers to the array with Aft[0] being the first item.

    So to use the & symbol it should have been

    name = &Aft[0];

    i.e. the address of the first element of the Aft.

    Paul.