Code
type
PFloat = pointer to float;
var
{$EEPROM}
EepFloat: float;
{$IDATA}
ptrfloat: PFloat;
ptr: pointer;
MyFloatValue: float;
begin
EepFloat := 3.14;
ptr := @EepFloat;
// this compiles:
ptrfloat := PFloat(ptr);
MyFloatValue := EEpromPtr(ptrfloat)^;
// error, this does not compile:
MyFloatValue := EEpromPtr(PFloat(ptr))^; // <<<<<<<<<<<<<< Why error?
end;
PFloat = pointer to float;
var
{$EEPROM}
EepFloat: float;
{$IDATA}
ptrfloat: PFloat;
ptr: pointer;
MyFloatValue: float;
begin
EepFloat := 3.14;
ptr := @EepFloat;
// this compiles:
ptrfloat := PFloat(ptr);
MyFloatValue := EEpromPtr(ptrfloat)^;
// error, this does not compile:
MyFloatValue := EEpromPtr(PFloat(ptr))^; // <<<<<<<<<<<<<< Why error?
end;
Is it just me or pointer dereferencing is not working in this case?
Example is very simplified. In real life I have 12 other types, not just float, I dereference from IDATA, EEPROM and UDATA at the same place, I convert all these types to string, and I have similar patterns repeated in many places, so solving this would make my code much more readable and less bloat.