Lazarus

Free Pascal => Beginners => Topic started by: joho on August 28, 2017, 08:57:31 pm

Title: THandle => LongInt => Throws compiler warning
Post by: joho on August 28, 2017, 08:57:31 pm

Building a Win32 console mode application, I was using FileOpen ... something like:

VAR
  FH : THandle;
BEGIN
  FH := FileOpen ('DoesNotExist', fmOpenRead);
  if (FH = -1) then
    Writeln ('No go');
  ..
  ..
END;

So I get a warning that FH (of type THandle) may never return -1 ... but I was under the impression that THandle was a LONGINT ... which is signed, no?

So if I can't use -1 as an "error return", what am I to check for (apart from the unsigned variant ... )?

Title: Re: THandle => LongInt => Throws compiler warning
Post by: engkin on August 28, 2017, 09:14:05 pm
feInvalidHandle or THandle(-1)
Title: Re: THandle => LongInt => Throws compiler warning
Post by: joho on August 28, 2017, 09:18:14 pm
Thank you, silly me for reading the docs :)
Title: Re: THandle => LongInt => Throws compiler warning
Post by: engkin on August 28, 2017, 09:25:09 pm
You are welcome. The short answer was not meant to imply the question was silly. Do not hesitate to ask when in doubt.  :)
Title: Re: THandle => LongInt => Throws compiler warning
Post by: joho on August 28, 2017, 09:29:14 pm
No offense taken (my skin is way too old for that) :)
The -1 reference I found was from the docs, so I *was* trying to be a good person and RTFM before asking.
There'll be many more questions I'm sure.
TinyPortal © 2005-2018