Recent

Author Topic: THandle => LongInt => Throws compiler warning  (Read 2173 times)

joho

  • Jr. Member
  • **
  • Posts: 69
  • Joaquim Homrighausen
    • ~/JoHo
THandle => LongInt => Throws compiler warning
« 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 ... )?


engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: THandle => LongInt => Throws compiler warning
« Reply #1 on: August 28, 2017, 09:14:05 pm »
feInvalidHandle or THandle(-1)

joho

  • Jr. Member
  • **
  • Posts: 69
  • Joaquim Homrighausen
    • ~/JoHo
Re: THandle => LongInt => Throws compiler warning
« Reply #2 on: August 28, 2017, 09:18:14 pm »
Thank you, silly me for reading the docs :)

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: THandle => LongInt => Throws compiler warning
« Reply #3 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.  :)

joho

  • Jr. Member
  • **
  • Posts: 69
  • Joaquim Homrighausen
    • ~/JoHo
Re: THandle => LongInt => Throws compiler warning
« Reply #4 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