Thanks a lot to all for your new replies.
Remember the {$IF} family (all of them) are unit local, so every other unit would need the same {$IF/$IFDEF}. Maybe that is the case.
Please have a look in my code in reply #4, everything is in the same unit.
I never encountered your issue, probably because I handle them correct by nature. (Which also means I can not explain it without full code)
Please find the full code attached in reply #4.
I remember now that I had the same issue with [$IF inside the "uses" clause in FPSpreadsheet, and it ended in writing an inc file with various manually set defines, e.g.
// Deactivate this define when the IDE knows the component TSpinEditEx, i.e. for Laz v1.8 or later
{$DEFINE USE_SPINEDITEX}
Include this inc file, named "test.inc" here, in every unit where it is needed.
...
Then there is the problem that you must change the define whenever you switch from the old to the new IDE and vice versa. A possible way to avoid this is to move the correct include file into a version-dependent directory and specify this in the project options' include-path by using the IDE macro $(LazVer). See attached project - it displays the text "SPINEDITEX is defined" or "SPINEDITEX is NOT defined" in the form caption depending on whether you compile the project from Laz 2.0.6 or Laz 1.6.4.
That is an interesting approach. And I learned how to use version-dependent directories via IDE macro $(LazVer). Thank you for that including the demo. But in my personal case I found it easier to include "-dNo_Unit_SpinEx" in the fpc.cfg of Lazarus 1.4.4 and 1.6.2 (I don't have more < 1.8.0) and then use it like:
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
{$IFNDEF No_Unit_SpinEx}
SpinEx,
{$ENDIF}
spin;
...
type
TForm1 = class(TForm)
...
{$IFNDEF No_Unit_SpinEx}
SpinEdit1: TSpinEditEx;
{$ELSE}
SpinEdit1: TSpinEdit;
{$ENDIF}
...
private
public
end;
What do others think: should I create a bug report (for the problem in reply #4)? If yes, please
howardpc give me the following infos, that I can include them:
- is it correct, that you got the same error message as me,
before you moved unit LCLVersion to the start of the uses clause?
- which revision# of FPC 3.3.1 did you use?
- which OS and version?
Thanks again to all for your valuable help.