In my C18 compiler (PIC, PIC18F66K22)
The following code:
char *message = "Test";
Leads to an empty string.
It's because "Test" would be saved in ROM, learned that the hard way…
But I believe it's valid C to do char *message = "Test";
so C18 is not compliant with the C-standard or how could I best describe this?
Is there an easy (withouth copying from ram to rom or using sprintf to put rom text in a ram variable?) way to specify that the text should be RAM?
I tried:
ram char *message;
message = (ram char *)"Test";
Without succes.
Best Answer
On the HiTech C compiler, a
char *
will be presumed to point to RAM; aconst char*
will be capable of accessing either RAM or ROM. I'm not positive that that convention has followed through to other compilers, but it's a useful and practical approach.