On Mon, Apr 25, 2005 at 03:22:31PM +0000, Joseph S. Myers wrote: > On Mon, 25 Apr 2005, Martin Koegler wrote: > > > The solution would be to add also for the base type of an array the > > eeprom attribute. Additonally all elements of structures and unions must > > also have the eeprom attribute added. > > The solution is to implement DTR18037 named address spaces. Naturally > such implementation involves implementing the proper semantics for the > types of structure element references.
As I don't know DTR18037 and have no access to it (even Google finds nothing useable about it), I cannot say something about it. I intend to create different address spaces in GCC using attributes, with only small changes in the core. As I test my ideas on my m68hc05 port, I describe my intended semantics using it, which is (apart for the problem with the incorrect types) already working: // shortcut for the attribute to write more compact #define E __attribute__ ((eeprom)) // An integer in the eeprom // for my port, I do the section selection using an other attribute int x E; typedef int eint E; struct x{ int x; int y; } struct y{ int x; struct x y; } typedef struct y ey E; struct y z E; struct y z1; int a[5] E; eint* a1; int* a2; int tmp; tmp=z.y.x; //do a load from the eeprom, in my case the same as a normal load z.y.x=2; //do a store to the eeprom a2=&z.y.x; //assignment of incompatible pointers *a2=1; //undefined a1=&z.y.x; *a1=1; // write to eeprom at z.y.x a[2]=1; // write to eeprom a1=a+1; // ok *a1=3; // write to a[1] in eeprom a2=a+1 //assignment of incomatible pointers *a1=3 //undefined void test(ey* ptr) { ptr->x=1; // write to eeprom } test(&z); //call test with z -> write 1 to z.x in the eeprom. z1=z // fails currently with a type error, but this should also work (copy from eeprom to z1) In the case of my port, a read using a normal pointer, which is load from a eeprom pointer, will succeed, in the case of AVR, such a operation will also be undefined. mfg Martin Kögler [EMAIL PROTECTED]