Forum > General

"$if declared()" directive

<< < (4/4)

MarkMLl:

--- Quote from: PascalDragon on December 02, 2021, 01:53:57 pm ---In mode Delphi since some time in the 2.0.x series, in mode ObjFPC since 2.2.0 and for all modes since 3.0.
...

It can very well be that this isn't mentioned in the release notes. Not everything is mentioned there...

--- End quote ---

Allowing that the context- at least of the thread as started- is .lpr files which are normally IDE-generated I presume mode ObjFPC applies.

The oldest FPC that I can possibly see myself running is 2.2.4 in order to run Lazarus building a GTK v1 app. I can't realistically see any reason I'd want to do that.

I do have one elderly 32-bit laptop which I use on occasion for testing comms hardware; because of old display hardware there's a complex kernel -> libraries -> apps progression which limits me to something like Lazarus 1.6.4 + FPC 3.0.2 on it hence the original question.

I think it's reasonable to assume that nobody will be running anything older, unless I (or anybody else) starts looking at e.g. SunOS/Solaris again where the available variant was- I think- limited to GTK1. I've done it in the past but really don't know how that squares with the versions above since Jonas et al. did various SPARC fixes around 2.7.1... it might be that I was able to use 2.7 or 3.0 on that platform but had to disable various packages.

A bit of looking at IDE sources earlier suggests that the other automatically-inserted line started appearing around Lazarus 1.0.0; in view of the combinations of Lazarus and FPC which realistically work together it is probably always safe to edit the .lpr to read


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---begin{$if LCL_FULLVERSION >= 1000000 }  RequireDerivedFormResource:=True;{$ifend                         }{$if LCL_FULLVERSION >= 1080000 }  Application.Scaled:=True;{$ifend                         }  Application.Initialize;... 
Anything substantially older than Lazarus 1.0 is likely to have other problems caused by tabbed control and Synedit changes, plus possibly a change in the resource directive. But I'd be surprised if anybody seriously tried that and expected code that old to be portable without significant issues.

Thanks also to Alex.

MarkMLl

PascalDragon:

--- Quote from: Alextp on December 02, 2021, 02:05:23 pm ---Yes, it is not mentioned at https://wiki.freepascal.org/FPC_New_Features_3.0.0 as I see. I don't know how to 'formulate it' in the wiki.

--- End quote ---

3.0.0 would be the wrong place anyway, as the original feature was added in 2.0.x, but only for mode Delphi.

MarkMLl:

--- Quote from: PascalDragon on November 30, 2021, 11:02:18 pm ---Declared() simply does not allow dots. It only allows identifiers (including generics) currently. I have it somewhere on my ToDo list to add support for dots as well, but we all know the problems with ToDo lists... %)

--- End quote ---

I note that (as of 3.2.2) it does however accept a unit name:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{ if declared(TMFRC522.PCD_PerformSelfTest) }  // Fails due to no dot etc. support{$if declared(mfrc522_diag) } // <----- Unit name (works){ if declared(TMFRC522H) }    // <----- Class helper in unit (works)      if mfrc522.PCD_PerformSelfTest() then        WriteLn('Selftest OK')      else        WriteLn('Selftest failed');{$endif                            } 
which is actually quite a comfortable way of handling things.

MarkMLl

Navigation

[0] Message Index

[*] Previous page

Go to full version