Hello alberto110,
As far as I remember, codevision interprets this,
flash char *name_lst_1[3]={"bread","milk","chicken"};
as
Array of pointers placed in RAM and pointing to strings in FLASH.
If you want
both the strings as well as pointers to strings in FLASH you will need,
flash char * flash name_lst_1[3]={"bread","milk","chicken"};
I don't understand why you want to send whole array to a function.
While individual strings are of different length, pointers to them(whether in RAM or FLASH) will be of same size. You just need to know the address of first element of array and the array length to access entire array from any function. Here is an example of accessing array of strings in flash using pointers in ram,
void func( flash char* ptr_str_flash, uint8_t a_len )
{
char str_ram[10]; // Just for example, size must have space for terminating '\0'
for( ; a_len; a_len-- ) {
strcpyf( str_ram, *ptr_str_flash ); // Note str_ram is indeed a pointer, passed as &str_ram[0]
// Must dereference the ptr_str_flash, since pointer is in RAM pointing
// to string in FLASH
// Using special function for CodeVision, RAM<-FLASH
ptr_str_flash++; // point to next string address
}
}
For any sane C compiler, sending any array as function parameter, inherently sends the pointer to first element of the array and pointer math(++, --) always calculates next element using the correct pointer size.
BTW, as per ANSI C, "const" only means you can't modify value directly. It does not specify where the variable actually is in the memory, since C does not inherently understands different memory types. So most of the compilers provide special attributes like flash, rom, code, eeprom etc.
Also as most c-critics like to point out, you can modify a "const" variable indirectly though a pointer.
const int i = 10; // Can init the var once
i = 15; // Error ! you can't modify a const
int* ptr = &i; // Pointer to i
*ptr = 15; // Hmm... You modified a const... Ouch...
Hope this helps,
sam_des