To support a legacy structure I need a 16-bit pointer. This to create a linked-list sort of structure. I need this to be declared compile-time, not runtime. Previously, we did this in assembly using Keil C166. The resulting pointers should be located in flash.
Example (pseudo code):
const int Temp = 123; unsigned short Ptr16 = (unsigned short)&Temp; // Doesn't work
This doesn't work: error: #69: integer conversion resulted in truncation
Any ideas how this could be done?
You can't play with pointers since the ARM chip doesn't use any 16-bit pointers. But if the data is stored within a limited block of memory, you could instead decide to store the offset relative the start of your data structure. This allows you to recreate a 32-bit pointer later.
But why don't you consider rewriting from 16-bit to 32-bit since whatever you do, you still need to make some changes?