Am 2013-11-10 06:57, schrieb Jim Leonard:
Using the FPC console IDE.  When I define a typed array with limits, ie.:
type
  tbarray=array[0..1023] of byte;
var
  foo:tbarray;
...I can view the contents of in the watch window (like "foo[2]") without 
problems.  But if I define it as a dynamic array:
type
  tbarray=array of byte;
var
  foo:tbarray;
...
setlength(foo,1024);

...then trying to view the array ("foo[2]") in the watch window shows up as "Cannot 
perform pointer math on incomplete types, try casting to a known type, or void *".  I've tried 
casting like byte(foo[2]) and byte^(foo[2]) but I must be doing it wrong as those aren't working.
What is the proper way to cast dynamic arrays so that I can inspect them in the 
watch window?

Dynamic arrays are actually *pointer* to arrays.
The compiler hides this fact from you because it automatically
dereferences the pointer when you use an index:

foo[i]
will be automatically expanded to
foo^[i]

But the debugger is not able to do this.
So you need to write

foo^[i]

when you want to examine this value in watch window or other debug windows.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to