This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Constant Strings

I have several constant strings that I defined as follows:

const u8 *Stringname = "StringContent";

At some stage if I add one more string, the uC stops working. I have more than enough code memory left so it is not a memory problem.

What could be the problem? Am I doing this the wrong way?
Should I put the strings in a different memory space?

Parents
  • At least in principle,

    u8 *Stringname = "StringContent";
    

    requires the compiler to allocate memory to store the string itself, plus more memory to store the pointer to the string.

    On the other hand,

    u8 String[] = "StringContent";
    

    only requires storage for the text.

    The question is: for a pointer to a const string, is the compiler smart enough to do away with the separate pointer...?

Reply
  • At least in principle,

    u8 *Stringname = "StringContent";
    

    requires the compiler to allocate memory to store the string itself, plus more memory to store the pointer to the string.

    On the other hand,

    u8 String[] = "StringContent";
    

    only requires storage for the text.

    The question is: for a pointer to a const string, is the compiler smart enough to do away with the separate pointer...?

Children
No data