Dear all,
I have some big tables constant data structures in my code, and I want them to reside in Flash. When I started few years ago, I remember I managed to do it putting quite a few const qualifiers around.
Recently I noticed, with newer versions of the compiler, that the tables are copied to RAM, wasting this precious resource.
I am using CCS latest version with compiler 5.1.3, but reverting back to 4.9.5 does not fix. I had an older compiler on my previous computer where the behavior was correct.
My question is: Is there a bug in my code that prevents the compiler to recognize the structures as constants, or there is a problem in the newer compilers?
Here is my code, simplified from the original enough to show the problem):
#include <stdio.h> extern const int ConstantInt; const int ConstantInt = 1234; typedef struct ConstantType { ConstantType(const unsigned int _a) : a(_a) {}; const unsigned int a; } ConstantType; extern const ConstantType ConstantStructure; const ConstantType ConstantStructure(1234); int main(void) { printf("%d, %d", &ConstantInt, ConstantStructure.a); return 0; }
In the above code the ConstantInt remains in Flash, while the ConstantStructure is copied to RAM.
Any Help?