embedded - How to create an array in C, writing to a specific memory address? -
i doing development on embedded system. need create array of integers using c. array must put in memory address, example, 0x12345678. integers in array should stored in chunk @ 0x12345678.
how can that?
regards, peter
it possible declare pointer assigned address, index thus:
static int* const arr = 0x12345678 ;
however, less satisfactory because size of array not defined, , if location in normal ram, nothing stops linker instantiating other objects there. if location refers i/o space or memory not in link map, may suffice.
the safe "linker aware" method tool-chain specific; gcc , arm realview example have __attribute__
extensions such purposes.
Comments
Post a Comment