Jump to content
David Schwartz

compiler setting issue?

Recommended Posts

Here's some code in a unit that compiles without error in a demo project (DX10.2):

function TVCLSFTPClientDemoForm.ListingCallback(const names: Pfxp_names): Boolean;
var StartRow,i:Integer;
begin
  StartRow:=sgRemoteFiles.RowCount;
  sgRemoteFiles.RowCount:=StartRow+names.nnames;
  for i:=0 to names.nnames-1 do begin
    sgRemoteFiles.Cells[0,StartRow+i]:=Utf8ToString(names.names[i].filename);
    sgRemoteFiles.Cells[1,StartRow+i]:=DateTimeToStr(TTimeZone.Local.ToLocalTime(UnixToDateTime(names.names[i].attrs.mtime)));
    if names.names[i].attrs.permissions and $F000 = $4000 then
       sgRemoteFiles.Cells[2,StartRow+i]:='<dir>'
    else
       sgRemoteFiles.Cells[2,StartRow+i]:=IntToStr(names.names[i].attrs.size);
    end;

When I paste this same code into another project that I created from scratch, I get errors saying "names.names is not an array" and it won't accept the [ i ] ]] subscript reference  (square brackets apparently control italics).

 

In fact, it's an array of pointers being returned from a DLL written in C/C++ where instead of using a subscript, it's probably using *p++ to iterate through the list.

 

Here's how the data structures are defined:

 

     fxp_attrs=record
       flags:TUnsignedLong;
       size: UInt64;
       uid,gid,
       permissions,
       atime,mtime:TUnsignedLong;
       end;
     Pfxp_attrs=^fxp_attrs;

     fxp_name=record
       filename,longname:PAnsiChar;
       attrs:fxp_attrs;
       end;
     Pfxp_name=^fxp_name;
     Tfxp_name_array=array[0..20000000] of fxp_name;
     Pfxp_name_array=^Tfxp_name_array;

     fxp_names=record
       nnames:Integer;
       names:Pfxp_name;
       end;
     Pfxp_names=^fxp_names;

 

I can't help but think this is probably a compiler flag somewhere. 

 

Any ideas?

 

 

Edited by David Schwartz

Share this post


Link to post
3 hours ago, FPiette said:

{$POINTERMATH ON} ?

Well, that's at the top of the 2 files with this code in it, so it looks like the culprit. I'll give it a try.

 

Yup, that solved it. Thanks!

Edited by David Schwartz
  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×