Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-07

Integer type?

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

I'm trying to use a Win32 API function, which is being called like this:

var
  BytesAvail : int64;
  BytesTotal : int64;
  BytesFree : int64;
  RootDir : array [1..4] of char;
GetDiskFreeSpaceEx (@RootDir,BytesAvail,BytesTotal,@BytesFree);

But when I compile I get this error:

Incompatible type for arg no. 3: Got INT64, expected LARGE_INTEGER

I've checked the .pdf files for the definition of LARGE_INTEGER, but I'm unable to locate that. The Win32 API Reference lists both the 2nd and 3rd args as PULARGE_INTEGER, so it seems a bit odd that the 2nd arg is being classified as okay while the 3rd isn't (unless the expression is being evaluated right to left, in which case the 2nd arg isn't checked yet and I just lied :-). I tried using -Sd too, but that didn't help either.

Obviously I'm doing something wrong here, but what is it?

BTW; -i tells me the following:
Free Pascal Compiler version 1.0.6
Compiler Date : 2002/04/23
Compiler Target: i386

TIA...

Jim

Rich Pasco
Show quoted text 13 lines
I'm trying to use a Win32 API function, which is being called like this: var BytesAvail : int64; BytesTotal : int64; BytesFree : int64; RootDir : array [1..4] of char; GetDiskFreeSpaceEx (@RootDir,BytesAvail,BytesTotal,@BytesFree); But when I compile I get this error: Incompatible type for arg no. 3: Got INT64, expected LARGE_INTEGER

That's because LARGE_INTEGER is not the same as int64. Changing your declarations to LARGE_INTEGER made the code compile OK.

I've checked the .pdf files for the definition of LARGE_INTEGER, but I'm unable to locate that.

It's defined in the Windows unit, which is not documented in the .PDF files. Looking in the source C:\pp\source\rtl\win32\wininc\struct.inc we see:

     LARGE_INTEGER = record
        case longint of
          0 : (LowPart : DWORD; HighPart : LONG);
          1 : (QuadPart : int64);
       end;
Show quoted text 5 lines
The Win32 API Reference lists both the 2nd and 3rd args as PULARGE_INTEGER, so it seems a bit odd that the 2nd arg is being classified as okay while the 3rd isn't (unless the expression is being evaluated right to left, in which case the 2nd arg isn't checked yet and I just lied :-).

I think that you answered your own question here.

- Rich

Rich Pasco

P.S. Here is a complete, working program, based on the information in my previous post:

uses Windows;
var
  BytesAvail : TLargeInteger;
  BytesTotal : TLargeInteger;
  BytesFree : TLargeInteger;
  RootDir : array [1..4] of char;
begin
  RootDir := 'C:\' + #$0;
  GetDiskFreeSpaceEx (@RootDir,BytesAvail,BytesTotal,@BytesFree);
  WriteLn(BytesAvail.quadpart, ' bytes avail');
  WriteLn(BytesTotal.quadpart, ' bytes total');
  WriteLn(BytesFree.quadpart,  ' bytes free');
end.
Unknown author

This worked great. Thanks for the help...

Rich Pasco
Sent by:
07/30/2002 08:56 PM
Please respond to fpc-pascal

To:
cc:
Subject: Re: [fpc-pascal]Integer type?

P.S. Here is a complete, working program, based on the information in my previous post:

uses Windows;
var
  BytesAvail : TLargeInteger;
  BytesTotal : TLargeInteger;
  BytesFree : TLargeInteger;
  RootDir : array [1..4] of char;
begin
  RootDir := 'C:\' + #$0;
  GetDiskFreeSpaceEx (@RootDir,BytesAvail,BytesTotal,@BytesFree);
  WriteLn(BytesAvail.quadpart, ' bytes avail');
  WriteLn(BytesTotal.quadpart, ' bytes total');
  WriteLn(BytesFree.quadpart,  ' bytes free');
end.