I want to declare an array of constant values in my header file, and this array cannot be changed in the main code.

const uchar x[4] = {1, 2, 3, 4} does not work, cos the linker will complain that the address space overflow.

Is there any way to do this?

Thanks in advance!


6 Years
Discussion Span
Last Post by Moschops

It was just an example.

I am trying to program into a Philips microcontroller, but it keeps returning an error when building, saying that the address space overflow.

This works in mircochip but not in the philips microcontroller.

I need an array that I can call and I do not want the program to change the values in the array.

So far I have googled and found nothing. Do you have any other ideas?

const unsigned char x[4] = {1, 2, 3, 4};

This works fine. I note that you're putting int values into char types; is that deliberate?


Sounds like the issue isn't your code, but the limitations of your hardware. Without knowing what your hardware limitations are, it's tricky to advise, but many such devices allow you to specify sections of memory to use. Dig out the manual and see what's available to you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.