Recent

Author Topic: How to know LCL version at compile time?  (Read 11300 times)

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1933
How to know LCL version at compile time?
« on: August 11, 2007, 09:07:42 pm »
How can I know against which LCL Version my source is compiled?

For example there is a change in GTKDef from 0.9.22 to 0.9.23 SVN:
From "ClipRegion: hRGN;" to "FClipRegion: PGdiObject;"

If I want my code to compile with the current stable version and the SVN version, I have to switch this.

Thanks

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: How to know LCL version at compile time?
« Reply #1 on: August 11, 2007, 09:41:21 pm »
As far as I know, you cannot know this.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1933
RE: How to know LCL version at compile time?
« Reply #2 on: August 11, 2007, 09:59:14 pm »
Thanks.
But it seems important in this case.
Should I place a feature request in the Bugtracker about this?
What do you think?

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: How to know LCL version at compile time?
« Reply #3 on: August 11, 2007, 11:06:27 pm »
I think it would be nice to have, but I don't see yet how this can be implemented.

Do you have an idea how this can be implemented?

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1933
RE: How to know LCL version at compile time?
« Reply #4 on: August 12, 2007, 12:04:38 am »
I'm not an expert but FPC does it with predefined Macros:

Table 2.1:    Predefined macros
   
Symbol    Contains
   
FPC_VERSION   The version number of the compiler.
FPC_RELEASE   The release number of the compiler.
FPC_PATCH    The patch number of the compiler.
   
You can then use them like:

{$if (fpc_version=0) and (fpc_release>6) and (fpc_patch>4)}  
{$info At least this is version 0.9.5}  
{$else}  
{$fatal Problem with version check}  
{$endif}


http://www.freepascal.org/docs-html/prog/progse5.html#x109-1090002.2
http://www.freepascal.org/docs-html/prog/progsu100.html#x114-1130002.4.2

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: How to know LCL version at compile time?
« Reply #5 on: August 12, 2007, 12:11:55 am »
Yes, a compiler can do that. I don't think it is feasible to patch the compiler each time you change lazarus version.

An option could be that lazarus passes -dLCL_0_9_23 to the compiler if the lazarus version in 0.9.23. I don't know if it is possible to pass constants like lcl_version=0 and lcl_minor=9 to the compiler.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1933
RE: How to know LCL version at compile time?
« Reply #6 on: August 12, 2007, 12:42:28 am »
Don't know if this is intelligent, but we could put this code in a lazver.inc file in the lcl dir:

  {$MACRO ON}
  {$Define lcl_version:=0}
  {$Define lcl_minor:=9}
  {$Define lcl_patch:=23}    

Then applications which need to know can include this file and use the info like:

{$ifdef lcl_version} {$ifdef lcl_minor} {$ifdef lcl_patch}
   {$if (lcl_version>=0) and (lcl_minor>=9) and (lcl_patch>=23)}
     Caption:='This is a version >= 0.9.23' ;
   {$endif}
  {$endif} {$endif}{$endif}
{$MACRO OFF}

Maybe not so clever for backward compatibility, when the lazver.inc file isn't there.
Maybe in combination with: -dHAVE_LCL_VER_FILE:

  {$IFDEF HAVE_LCL_VER_FILE}
    {$I lazver.inc}
  {$ENDIF}  

But you certainly know a better solution ;-)

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2674
RE: How to know LCL version at compile time?
« Reply #7 on: August 14, 2007, 02:39:40 pm »
I see no need for is. As long as the lcl is not 1.0 interfaces might change. After that is should stay the same.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: How to know LCL version at compile time?
« Reply #8 on: November 23, 2007, 08:30:04 am »
Because it changes, component developers need to know what version they compile against.

I think we need this feature. Theo, can you create a bug report. I will look into it.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1933

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2674
RE: How to know LCL version at compile time?
« Reply #10 on: November 23, 2007, 01:12:51 pm »
either way (i' still not convinced), you don't need defines, putting it constants works too (and can evenbe used in code when needed)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1933
RE: How to know LCL version at compile time?
« Reply #11 on: November 23, 2007, 01:20:25 pm »
It's just an idea.
How would you do that with constants?

 

TinyPortal © 2005-2018