[ColdFire] array of pointers to constant objects?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[ColdFire] array of pointers to constant objects?

1,649 Views
KRichard
Contributor II
Hello!

I would like my "data" variable to be an array of pointers pointing to the values I specify (which are constant and known at compile time).

In GCC it looks something like this:
const void* const data[] = { 0x01, "foo", 0x02, "bar" };

It doesn't work in CodeWarrior, any help / hints would be appreciated.

Thanks in advance,
Richard
Labels (1)
0 Kudos
1 Reply

263 Views
CompilerGuru
NXP Employee
NXP Employee
did you try to cast the int's to (void*).
I don't think it is legal to assign (implicitly convert) any integer besides 0, so I would try to cast the 0x01.
So I would try something like (not compiled on my own):
const void* const data[] = { (const void*)0x01, "foo", (const void*)0x02, "bar" };

Or, depending on your needs, may not aply in your setup:
struct elem { int val, void* ptr};
const struct elem data[]= { {0x01, "foo"}, {0x02,"bar"}};

Daniel
0 Kudos