cancel
Showing results for 
Search instead for 
Did you mean: 

Can not assign Unsigned char = unsigned char ?

antonius
Senior
Posted on October 16, 2015 at 23:05

Guys,

I tried to use unsigned char below, but I got error, how can I fix it ?

                

[CODE]const unsigned char data[] = {0xFF,0xF2,0x40,0xC0,0x19,0xB7,0x00,0x14,0x02,0xE6,0x5C,};

unsigned char *q;

q = data ;    [/CODE]

[CODE]..\Src\main.c(274): error:  #513: a value of type ''const unsigned char *'' cannot be assigned to an entity of type ''unsigned char *''

                q = data;[/CODE] 

Thanks
1 REPLY 1
Posted on October 17, 2015 at 01:41

Well you could make the pointer a const one, or lose the const directive on the data.

You could also explicitly cast it.

const means the content is unchangeable and can be placed in ROM/FLASH, the compiler is trying to enforce rules so you don't try to write to the data structure. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..