Hi everyone,
I'm working with CW 10.2 and Kinetis MK60DN512.
I created a bareboard project with a single test file:
#include <stdio.h>
#include "derivative.h" /* include peripheral declarations */
typedef struct
{
const char *str;
} TEST;
const TEST Test0 =
{
"STRING0"
};
const TEST Test1 =
{
"STRING1"
};
const TEST *Test[ 2 ] =
{
&Test0,
&Test1
};
int main( void )
{
int i;
for( i = 0; i < 2; i++ )
printf( Test[ i ]->str );
while( 1 )
{
i++;
}
return( 0 );
}
In the map file the two const structs Test0 and Test1 are located in .rodata section (flash), but the const struct Test is located in the .app_data section (ram) even if it's declared as const.
Why is there such difference? I expected all the structs to be located in the .rodata section.
Many thanks
Teckna
Solved! Go to Solution.
Hello,
because Test[] is not const. Test is a non-const array of two pointers to const structs.
To make it const, you have to define it as
const TEST *const Test[] =
Erich
Hello,
because Test[] is not const. Test is a non-const array of two pointers to const structs.
To make it const, you have to define it as
const TEST *const Test[] =
Erich
Many thanks, Erich,
Teckna
Hi
See the following for some ideas about forcing more things to Flash - it is for CW7 but may be the same for CW10
Regards
Mark