Hello,
FPC v3.2.2 & Lazarus v3.99 (2024-10-23)
Consider the following code:
{$APPTYPE CONSOLE}
program _WatchEnums;
uses
Windows
;
type
{$PACKENUM 1}
TDATA_TYPE = { prefix: dt_ }
(
dt_not_examined = 0,
dt_unknown,
dt_code_first,
dt_code_last,
dt_data_first,
dt_data_last,
{ make the filler and markers easy to recognize by setting their numeric }
{ values to easily identifiable numbers }
dt_pe_filler_first = 240, { filler is supposed to be }
dt_pe_filler_code, { inaccessible }
dt_pe_filler_data,
dt_pe_filler_last,
dt_markers_first = 250,
dt_marker_bottom, { bottom message map sentinel }
dt_marker_top, { top " " " }
dt_markers_last
);
{$PACKENUM 4}
type
TRECORD = record
field_value : DWORD;
field_type : TDATA_TYPE;
field_info : array[0..5] of DWORD;
end;
function AFunction : boolean;
var
Table : array[0..9] of TRECORD;
ti : DWORD = 0;
begin
result := FALSE;
ZeroMemory(@Table, sizeof(Table));
for ti := 0 to 3 do
begin
with Table[ti] do
begin
field_value := ti;
Field_info[0] := ti;
case ti of
0 : field_type := dt_marker_bottom;
1, 2 : field_type := dt_pe_filler_code;
3 : field_type := dt_marker_top;
end;
end;
end;
result := TRUE;
end;
begin
AFunction();
readln;
end.
When watching the values of the "Table" array, the values of "field_type" are not as expected.
field_type is defined to be of type TDATA_TYPE which consists of all positive constants yet the watch window shows the values assigned to "field_type" to be negative. (please see attachment.)
Is the compiler posting incorrect symbols for TDATA_TYPE or is the debugger (FpDebug) misinterpreting them ?
it would be nice if the values in the watch window were as they are defined in the data type, i.e,
240 241 instead of -15,
250 251 instead of -5 and
251 252 instead of -4.
comments welcome.
ETA:Added forgotten attachment.
Corrected the expected values which were originally off by one in the text.