pointer dereferencing problem

Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

pointer dereferencing problem

 · 
Posted: 12.08.2014 - 14:03  ·  #1
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;


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.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: pointer dereferencing problem

 · 
Posted: 12.08.2014 - 18:04  ·  #2
Hello Avra,

EEpromPtr and FlashPtr expect a simple pointer. Your construction is not supported yet.

rolf
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   47   61 · Page-Gen-Time: 0.041686s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI