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

defining an array of pointers to structure members generates compiler error

espression must have a constant value

i have a static struct variable having struct members and have to access this members on change of a count. so instead of using a switch case statement to load respective struct member (address) into a pointer, i thought of defining a local array of pointers to point struct members.
but i get above error.
I tried to specifically define the struct at address 0xA0000000 of my parallel SDRAM using __attribute__ ((at(0xA0000000)))

how can this be achieved using an array of pointers??

PS: LPC1788 - but dont think the problem is architecture dependent.

Parents
  • how else will the code know what to do with a generic pointer that sometimes points to a struct of one type and at other times points to a struct of a different type?
    All the structures actually have character arrays where ascii values are stored. i have created structure & structure of structures (which contain the arrays) to organise the data which i can then access according to structures (groups).

    And i want to create an array of pointers (i.e. address of memory locations). hence (according to me) compiler should only see it as an array of pointers to 1byte memory locations.

    an array will make it easy to load the address into the pointer and start accessing the data from there.

Reply
  • how else will the code know what to do with a generic pointer that sometimes points to a struct of one type and at other times points to a struct of a different type?
    All the structures actually have character arrays where ascii values are stored. i have created structure & structure of structures (which contain the arrays) to organise the data which i can then access according to structures (groups).

    And i want to create an array of pointers (i.e. address of memory locations). hence (according to me) compiler should only see it as an array of pointers to 1byte memory locations.

    an array will make it easy to load the address into the pointer and start accessing the data from there.

Children
No data