Recent

Author Topic: {$IFDEF LAZ_VERSION} ?  (Read 12304 times)

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
{$IFDEF LAZ_VERSION} ?
« on: November 13, 2014, 01:50:54 pm »
Hi all..  ;)


Is there a way for detecting in which version of lazarus the code being compiled?


For example, I have a line of code that should only compiled within Lazarus 1.3 up like this:


Code: [Select]

TDesignerMediator = class(TComponent)
...
public
   {$IF DEFINED( LAZ_VER_1_3) OR DEFINED( LAZ_TRUNK ) OR DEFINED( LAZ_VER_1_2_8 )}
    procedure OiNodeGetImageIndex(APersistent: TPersistent; var AIndex: integer); override;
   {$ENDIF}
...
end;


or, is there similar way to do that?


Thanks you.
x2nie
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: {$IFDEF LAZ_VERSION} ?
« Reply #1 on: November 13, 2014, 01:58:15 pm »
http://lazarus-ccr.sourceforge.net/docs/lcl/lclversion/

using lcl_fullversion is handy:
from my notes
Code: [Select]
uses ...LCLVersion...
...
{$IF LCL_FULLVERSION>=1000000} //for laz 1.0.0.0 (major,minor,release,patch)
{$IF LCL_FULLVERSION>=1000200} //for laz 1.0.2.0
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Fred vS

  • Hero Member
  • *****
  • Posts: 3808
    • StrumPract is the musicians best friend
Re: {$IFDEF LAZ_VERSION} ?
« Reply #2 on: November 13, 2014, 02:06:43 pm »
Hello everybody.

Hum, by the way, where can i find a list of all the $pre-defined fpc compiler things (i do not know how you call that {$...}) ?

For example =>
 (FPC_FULLVERSION)
 DEFINED(LCL)
etc...
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12706
  • FPC developer.
Re: {$IFDEF LAZ_VERSION} ?
« Reply #3 on: November 13, 2014, 02:24:28 pm »
The FPC ones are in the manual.

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: {$IFDEF LAZ_VERSION} ?
« Reply #4 on: November 13, 2014, 02:27:48 pm »
Thanks @BigChimp for quick reply.


Yes, you right. It is running (compiled) perfectly like a charm ! 8-) I mean, like I expected.


--------------------------
Anyway, the LCL_FullVersion constant aren't recognized properly by SynEdit (Codetools?).
(see below screenshot)
But, this bug is only cosmetic level. The compiler-directive is exactly known by fpc.
I Even don't know whether if it is has been fixed in trunk,
nowadays I play only with Lazarus 1.2.6


Somebody else who uses Lazarus Trunk please confirm if this bug still in lazarus-trunk-codes.
---------------


Regards,
x2nie
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

x2nie

  • Hero Member
  • *****
  • Posts: 515
  • Impossible=I don't know the way
    • impossible is nothing - www.x2nie.com
Re: {$IFDEF LAZ_VERSION} ?
« Reply #5 on: November 13, 2014, 03:13:24 pm »

Anyway, the LCL_FullVersion constant aren't recognized properly by SynEdit (Codetools?).
(see below screenshot)
But, this bug is only cosmetic level. The compiler-directive is exactly known by fpc.
I Even don't know whether if it is has been fixed in trunk,
nowadays I play only with Lazarus 1.2.6

Somebody else who uses Lazarus Trunk please confirm if this bug still in lazarus-trunk-codes.


Hey, I finally found a quick solution for this cosmetic-level-bug (which is somehow annoying) :
  • Use lessthan sign ( "<" ) instead of greaterthan ( ">" ), when test/comparing constant value in compiler directive !
Again,
This is shown as wrong:

  //In fact, I am using Lazarus 1.2.6

  {$if LCL_FULLVERSION > 1020000} //for laz 1.2.6.0 (major,minor,release,patch)
  caption := 'You are using Lazarus 1.2.6 up';  // <--- annoying here
  {$ELSE}
  caption := 'You are using old Lazarus before 1.2.6';
  {$ENDIF}                                 

This one shown as correct:

    //In fact, I am using Lazarus 1.2.6

  {$if LCL_FULLVERSION < 1030000} //for laz 1.3.0.0 (major,minor,release,patch)
  caption := 'You are using old Lazarus before 1.3.0';  // <-- it is as expected.
  {$ELSE}
  caption := 'You are using Lazarus 1.3.0 or newer!';
  {$ENDIF}   

Below pictures show what the difference.
When you were logged in, you can see attachments.
Lazarus Github @ UbuntuCinnamon-v22.04.1 + LinuxMintDebianEdition5

Fred vS

  • Hero Member
  • *****
  • Posts: 3808
    • StrumPract is the musicians best friend
Re: {$IFDEF LAZ_VERSION} ?
« Reply #6 on: November 13, 2014, 08:05:16 pm »
Quote
The FPC ones are in the manual.

Wow, thanks for that marvelous tip.  ;)

Hum, i read /fpc/doc/fcl, fcl, prog, ref, rtl, user and search on wiki but did not find it.

For example, in fpc 2.7.1.  => {$DEFINE Console} is internally defined but not in fpc 2.6.0.

It would be great if i could find a list of all the pre-defined things, per fpc version.
A Lazarus list would be welcome too.

Fre;D

« Last Edit: November 13, 2014, 08:12:15 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12706
  • FPC developer.
Re: {$IFDEF LAZ_VERSION} ?
« Reply #7 on: November 13, 2014, 09:57:23 pm »
Quote
The FPC ones are in the manual.

Wow, thanks for that marvelous tip.  ;)

Hum, i read /fpc/doc/fcl, fcl, prog, ref, rtl, user and search on wiki but did not find it.

Such things are in prog. http://www.freepascal.org/docs-html/prog/progse5.html
 

Fred vS

  • Hero Member
  • *****
  • Posts: 3808
    • StrumPract is the musicians best friend
Re: {$IFDEF LAZ_VERSION} ?
« Reply #8 on: November 13, 2014, 11:02:04 pm »
Quote
Such things are in prog. http://www.freepascal.org/docs-html/prog/progse5.html

Yep many thanks Marcov  (this one, i did not see) :-[

But, it is only one part of the predefined macros =>

Quote
Symbol    Contains
   
FPC_FULLVERSION   An integer version number of the compiler.
FPC_VERSION    The version number of the compiler.
FPC_RELEASE    The release number of the compiler.
FPC_PATCH    The patch number of the compiler.

What i am looking for is all the predefined macros used by fpc (and Lazarus),
For example, {$IFDEF Console}, {$DEF library}, {$DEF LCL}, etc...

Where can i find a list of all that predefined macros ?

For example, if i use {$IFDEF Console} in a console application with fpc 2.6.0., the result will be false and true with fpc 2.7.1 => So a list of predefined macros (i do not know if it is the right word for that) will be useful.

Thanks.

Fre;D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: {$IFDEF LAZ_VERSION} ?
« Reply #9 on: November 13, 2014, 11:06:28 pm »
Check via Lazarus IDE. Look at View->IDE Internals->About FPC/About IDE.

Fred vS

  • Hero Member
  • *****
  • Posts: 3808
    • StrumPract is the musicians best friend
Re: {$IFDEF LAZ_VERSION} ?
« Reply #10 on: November 13, 2014, 11:15:57 pm »
@ Cyrax => You are the winner => Many thanks and Big Congrat =>

Code: [Select]
Defines:
CONSOLE=
CPU64=
CPUAMD64=
CPUATHLON64=
CPUX64=
CPUX86_64=
CPUX86_HAS_SSEUNIT=
ENDIAN_LITTLE=
FPC=
FPC_ABI_DEFAULT=
FPC_DYNARRAYCOPY_FIXED=
FPC_FULLVERSION=20701
FPC_HASFIXED64BITVARIANT=
FPC_HASINTERNALOLEVARIANT2VARIANTCAST=
FPC_HAS_CEXTENDED=
FPC_HAS_CONSTREF=
FPC_HAS_CPSTRING=
FPC_HAS_FEATURE_ANSISTRINGS=
FPC_HAS_FEATURE_CLASSES=
FPC_HAS_FEATURE_COMMANDARGS=
FPC_HAS_FEATURE_CONSOLEIO=
FPC_HAS_FEATURE_DYNARRAYS=
FPC_HAS_FEATURE_DYNLIBS=
FPC_HAS_FEATURE_EXCEPTIONS=
FPC_HAS_FEATURE_EXITCODE=
FPC_HAS_FEATURE_FILEIO=
FPC_HAS_FEATURE_HEAP=
FPC_HAS_FEATURE_INITFINAL=
FPC_HAS_FEATURE_OBJECTIVEC1=
FPC_HAS_FEATURE_OBJECTS=
FPC_HAS_FEATURE_PROCESSES=
FPC_HAS_FEATURE_RANDOM=
FPC_HAS_FEATURE_RESOURCES=
FPC_HAS_FEATURE_RTTI=
FPC_HAS_FEATURE_SOFTFPU=
FPC_HAS_FEATURE_STACKCHECK=
FPC_HAS_FEATURE_SUPPORT=
FPC_HAS_FEATURE_TEXTIO=
FPC_HAS_FEATURE_THREADING=
FPC_HAS_FEATURE_UNICODESTRINGS=
FPC_HAS_FEATURE_VARIANTS=
FPC_HAS_FEATURE_WIDESTRINGS=
FPC_HAS_INTERNAL_ABS_INT64=
FPC_HAS_INTERNAL_ABS_LONG=
FPC_HAS_INTERNAL_BSF=
FPC_HAS_INTERNAL_BSR=
FPC_HAS_INTERNAL_ROX=
FPC_HAS_INTERNAL_SAR=
FPC_HAS_MEMBAR=
FPC_HAS_OPERATOR_ENUMERATOR=
FPC_HAS_RESSTRINITS=
FPC_HAS_RIP_RELATIVE=
FPC_HAS_STR_CURRENCY=
FPC_HAS_TYPE_DOUBLE=
FPC_HAS_TYPE_EXTENDED=
FPC_HAS_TYPE_SINGLE=
FPC_HAS_UNICODESTRING=
FPC_HAS_VALGRINDBOOL=
FPC_HAS_VARSETS=
FPC_HAS_WINLIKERESOURCES=
FPC_LINK_STATIC=
FPC_LITTLE_ENDIAN=
FPC_OBJFPC_EXTENDED_IF=
FPC_PATCH=1
FPC_REAL2REAL_FIXED=
FPC_RELEASE=7
FPC_RTTI_PACKSET1=
FPC_SETBASE_USED=
FPC_STATICRIPFIXED=
FPC_STRTOCHARARRAYPROC=
FPC_STRTOSHORTSTRINGPROC=
FPC_VARIANTCOPY_FIXED=
FPC_VERSION=2
FPC_WIDESTRING_EQUAL_UNICODESTRING=
FPUSSE64=
HASUNIX=
INTERNAL_BACKTRACE=
LINUX=
REGCALL=
RESSTRSECTIONS=
STR_CONCAT_PROCS=
UNIX=
VER2=
VER2_7=
VER2_7_1=

Much better but... =>

It is not the all list... => for example LIBRARY= is missing and lot of others...  :-[  :-X

Fre;D

[EDIT] It seems that this list is the predefined macros used by current Lazarus/fpc version, so it is only some predefined macros, not the all list that fpc is using...
« Last Edit: November 13, 2014, 11:23:02 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12706
  • FPC developer.
Re: {$IFDEF LAZ_VERSION} ?
« Reply #11 on: November 14, 2014, 10:26:43 am »
[EDIT] It seems that this list is the predefined macros used by current Lazarus/fpc version, so it is only some predefined macros, not the all list that fpc is using...

Some might be introduced by Lazarus, some are version dependent. (so the ones that add to 2.7.1 will only be documented if 2.7.1 goes gold), some are mostly for internal/temporary use and are undocumented.

The FPC_HAS* are somewhat inbetween. Some of those are for embedded users to more easily write cut down RTLs. There is some use in that corner, but mostly undocumented

Fred vS

  • Hero Member
  • *****
  • Posts: 3808
    • StrumPract is the musicians best friend
Re: {$IFDEF LAZ_VERSION} ?
« Reply #12 on: November 14, 2014, 01:06:12 pm »
Thank you Marcov to answer.  ;)

Quote
here is some use in that corner, but mostly undocumented

I know (and you too) that i am boring to insist all the time but, really, a list of all predefined macros will be useful. For example, for cpu used, it could be {$if defined(cpu64) and other declarations that i do not know, idem for os, {$IFDEF Windows} could be used but {$IFDEF Win32} aswell,  idem for lot of other declarations.

If i could help to do that list, i will do it with pleasure (but i do not know where to find the data).

Fre;D

I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: {$IFDEF LAZ_VERSION} ?
« Reply #13 on: November 14, 2014, 01:10:19 pm »
See the manuals. CPU64 etc predefined symbols are there. There's also a wiki page copying the exact same information.

I'm not going to google for you - I'm sure you can do that yourself.
« Last Edit: November 14, 2014, 01:12:40 pm by BigChimp »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Fred vS

  • Hero Member
  • *****
  • Posts: 3808
    • StrumPract is the musicians best friend
Re: {$IFDEF LAZ_VERSION} ?
« Reply #14 on: November 14, 2014, 01:15:10 pm »
Code: [Select]
See the manuals. CPU64 etc are there. There's also a wiki page copying the exact same information.
I'm not going to google for you - I'm sure you can do that yourself.

Thanks BigChimp.  Hum, please, what is the right word for that {$IFDEF LAZ_VERSION} things,
is it "predefined macros" ?

Thanks.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018