Question on C for anyone who can answer.
I have an array of unsigned chars representing bytes called memory[], and a structure called data. I want to be able to assign the address of the first item in memory[], to the structure so subsequent indeces (sp?) will be represented in fields. I've tried the following:
data *Ins_RR = memory;
data *Ins_RR = &memory[0];
But the compiler complains about both with the following error message:
-- RR *Ins_RR = &memory[0];
-- ^
-- cp.c(113) : Error: need explicit cast to convert
-- from: char (*)[1]
-- to : struct Register_to_Register*
-- --- errorlevel 1
So I try to cast:
data *Ins_RR = (data)memory;
But then it tells me:
-- RR *Ins_RR = (RR)memory;
-- ^
-- cp.c(113) : Error: illegal cast
-- from: char (*)[1]
-- to : struct Register_to_Register
-- --- errorlevel 1
Can anyone show me how to do this properly? Thanks ahead.
I have an array of unsigned chars representing bytes called memory[], and a structure called data. I want to be able to assign the address of the first item in memory[], to the structure so subsequent indeces (sp?) will be represented in fields. I've tried the following:
data *Ins_RR = memory;
data *Ins_RR = &memory[0];
But the compiler complains about both with the following error message:
-- RR *Ins_RR = &memory[0];
-- ^
-- cp.c(113) : Error: need explicit cast to convert
-- from: char (*)[1]
-- to : struct Register_to_Register*
-- --- errorlevel 1
So I try to cast:
data *Ins_RR = (data)memory;
But then it tells me:
-- RR *Ins_RR = (RR)memory;
-- ^
-- cp.c(113) : Error: illegal cast
-- from: char (*)[1]
-- to : struct Register_to_Register
-- --- errorlevel 1
Can anyone show me how to do this properly? Thanks ahead.