How to know LCL version at compile time? lazarus / 7-LCL ---------------------------------------------------------------------- theo · 2007-08-11 19:07 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 · 2007-08-11 19:41 As far as I know, you cannot know this. ---------------------------------------------------------------------- theo · 2007-08-11 19:59 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 · 2007-08-11 21:06 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 · 2007-08-11 22:04 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 · 2007-08-11 22:11 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 · 2007-08-11 22:42 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 · 2007-08-14 12:39 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. ---------------------------------------------------------------------- Vincent Snijders · 2007-11-23 07:30 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 · 2007-11-23 11:51 OK, done: http://www.freepascal.org/mantis/view.php?id=10250 ---------------------------------------------------------------------- Marc · 2007-11-23 12:12 either way (i' still not convinced), you don't need defines, putting it constants works too (and can evenbe used in code when needed) ---------------------------------------------------------------------- theo · 2007-11-23 12:20 It's just an idea. How would you do that with constants?