$IF DEFINED(xxx) <> $IFDEF xxx when using $ELSEIF DEFINED(xxx)
Original Reporter info from Mantis: ArminLinder
-
Reporter name: Armin Linder
Original Reporter info from Mantis: ArminLinder
- Reporter name: Armin Linder
Description:
{ELSEIF DEFINED(...)} fails to recogize a previous {
IFDEF ..} and gives a misleading error message, using {$IF DEFINED(...)} instead works, but $IF seems to be weakly documented, as this behaviour if $IF DEFINED is.
Steps to reproduce:
unit Unit1;
{mode objfpc}{
H+}
interface
{$IFDEF WIN64}
// ...
{$ELSEIF DEFINED(WINDOWS)}
// ...
{$ENDIF}
implementation
{$R *.lfm}
end.
---> unit1.pas(9,9) Error: ENDIF without IF(N)DEF
This works:
{$IF DEFINED(WIN64)}
// ...
{$ELSEIF DEFINED(WINDOWS)}
// ...
{$ENDIF}
Additional information:
Either a flaw in the compiler, or in the documentation, where $IF isn't covered at all (appears in a code sample, but no explanations), and a misleading error message. May have been working in previous FPC versions, since it comes from a publicly available FPC code library (OpenSSL by mgaertner) (--> https://github.com/graemeg/freepascal/b ... penssl.pas) line 93, which should have compiled in the past.
Mantis conversion info:
- Mantis ID: 38793
- OS: Windows 10 x64
- OS Build: Version 10.0.190
- Version: 3.2.0