waldo kitty schrieb:
On 6/3/2013 13:52, Mattias Gaertner wrote:
On Mon, 3 Jun 2013 19:12:44 +0200
Marco van de Voort<[email protected]>  wrote:

On Mon, Jun 03, 2013 at 05:00:46AM -0400, waldo kitty wrote:
why does this constant not exist in FPC or Lazarus?

have i been looking in the
wrong place or for the wrong thing?

C:\repo\fpc\rtl\win\wininc>grep INVALID_HANDLE_VALUE *
defines.inc:     INVALID_HANDLE_VALUE = HANDLE(-1);

I changed the constant in LCLType accordingly.

thanks, i think :)

what can we do about INVALID_FILE_SIZE?

  const
    INVALID_FILE_SIZE = DWORD($FFFFFFFF);

is the above correct? it would seem to be from what i can make out from MSDN and the various C code files i've found it defined in...

Using unsigned constants with int64 filesizes would classify files of exactly that size as invalid, while smaller or bigger files would be valid. This certainly is *not* what the coder had in mind, so that I'd suggest to inspect and fix all occurences of this (and similar) unsigned constants in user code.

i kind of have to laugh because on place i read spoke of examples checking the result directly instead of using INVALID_FILE_SIZE and that this was not good coding practice because m$ might change the value of INVALID_FILE_SIZE at any time which would then break all of that code... i makes sense to me O:)

IMO such unsigned constants should be used only in specific cases, e.g. with OS defined records containing part of an longer (int64) type. The FCL can use that constant in Win32 platform code, the LCL or user code never should use it at all.

I also doubt that the MS documentation is up to date whenever above constant is used with anything except struct fields of type DWORD. Even in 32 bit code *both* low/high parts of a 64 bit filesize must be checked for INVALID_FILE_SIZE, in order to determine a valid result.

DoDi


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to