Hi,

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!

YYE

Recommended Answers

All 3 Replies

const unsigned char x[4] = {1, 2, 3, 4};
http://ideone.com/EHqa1

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

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};
http://ideone.com/EHqa1

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.