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

array problem

Hi all

I've a array located at code segment named

StandardModeType is a struct has some integer values

StandardModeType code StandardModeTable_rc7_17[]={
...
}

I want to creat a pointer in xdata and I want to creat a poiter to access them using

StandardModeType code *xdata StandardModeTable_rc7[];


altough my variable show the right place at code memory, when I try to display values for these variable two different values exist.
StandardModeTable_rc7[0]->StdVFreq
StandardModeTable_rc7_17[0].StdVFreq

what can cause this problem? Any idea.

Parents
  • Here..

    StandardModeType code StandardModeTable_rc7_17[]={
      ...
      /* you put data in here */
    }
    

    .. you define the array size by filling it with data. Say you put 5 values in it and the array will have 5 elements (index 0 to 4).

    After that you create an array of pointers:

    StandardModeType code *xdata StandardModeTable_rc7[];
    

    This array (of pointers) has no size specified. It should have at least the same size as StandardModeTable_rc7_17. Now you're just writing to undefined memory.

    So... Put a number between [ and ].

Reply
  • Here..

    StandardModeType code StandardModeTable_rc7_17[]={
      ...
      /* you put data in here */
    }
    

    .. you define the array size by filling it with data. Say you put 5 values in it and the array will have 5 elements (index 0 to 4).

    After that you create an array of pointers:

    StandardModeType code *xdata StandardModeTable_rc7[];
    

    This array (of pointers) has no size specified. It should have at least the same size as StandardModeTable_rc7_17. Now you're just writing to undefined memory.

    So... Put a number between [ and ].

Children