[SOLVED] Cleanup of duplicate declarations of constants lazarus / 7-LCL ---------------------------------------------------------------------- lagprogramming · 2023-07-09 14:30 Both lcl/interfaces/win32/win32extra.pas and lcl/interfaces/customdrawn/customdrawn_winextra.pas files contain the following lines: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i { Win32 API constants not included in windows.pp }const  // Layout orientation  LAYOUT_RTL                        = $00000001; // Right to left  LAYOUT_BTT                        = $00000002; // Bottom to top  LAYOUT_VBH                        = $00000004; // Vertical before horizontal  LAYOUT_ORIENTATIONMASK            = (LAYOUT_RTL or LAYOUT_BTT or LAYOUT_VBH);  LAYOUT_BITMAPORIENTATIONPRESERVED = $00000008;  // not defined in fpc 2.4.3  GCLP_HBRBACKGROUND              = -10; The above constants have been included in FPC's rtl through the following commits: Oct 17, 2010 Commit 8304d2c1: * adds gwlp and gclp constants, mantis 17656 and 17655 https://gitlab.com/freepascal.org/fpc/source/- /commit/8304d2c1c5240cd8292b87ca2835bfb3f988d1fe Jul 06, 2013 Commit 609f6255: * added layout constants. https://gitlab.com/freepascal.org/fpc/source/- /commit/609f6255d4d371c993d8e231efc83ee97523d9bd This means that the constants declarations in the LCL have become obsolete 10 years ago. The ones in FPC's rtl should be enough. The following patch removes the declarations from the LCL. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i diff --git a/lcl/interfaces/customdrawn/customdrawn_winextra.pas b/lcl/interfaces/customdrawn/customdrawn_winextra.pasindex 1d7a36da24..d155284efe 100644--- a/lcl/interfaces/customdrawn/customdrawn_winextra.pas+++ b/lcl/interfaces/customdrawn/customdrawn_winextra.pas@@ -43,17 +43,6 @@ type     DisabledWindows: TList;   end; -{ Win32 API constants not included in windows.pp }-const-  // Layout orientation-  LAYOUT_RTL                      = $00000001; // Right to left-  LAYOUT_BTT                      = $00000002; // Bottom to top-  LAYOUT_VBH                      = $00000004; // Vertical before horizontal-  LAYOUT_ORIENTATIONMASK            = (LAYOUT_RTL or LAYOUT_BTT or LAYOUT_VBH);-  LAYOUT_BITMAPORIENTATIONPRESERVED = $00000008;-  // not defined in fpc 2.4.3-  GCLP_HBRBACKGROUND                = -10;- type   tagMENUBARINFO = record     cbSize: DWORD;diff --git a/lcl/interfaces/win32/win32extra.pas b/lcl/interfaces/win32/win32extra.pasindex 5997d81fe4..9d7bdc7787 100644--- a/lcl/interfaces/win32/win32extra.pas+++ b/lcl/interfaces/win32/win32extra.pas@@ -28,17 +28,6 @@ interface uses    Classes, LCLType, Windows, GraphType, SysUtils, ActiveX, ShlObj; -{ Win32 API constants not included in windows.pp }-const-  // Layout orientation-  LAYOUT_RTL                        = $00000001; // Right to left-  LAYOUT_BTT                        = $00000002; // Bottom to top-  LAYOUT_VBH                        = $00000004; // Vertical before horizontal-  LAYOUT_ORIENTATIONMASK            = (LAYOUT_RTL or LAYOUT_BTT or LAYOUT_VBH);-  LAYOUT_BITMAPORIENTATIONPRESERVED = $00000008;-  // not defined in fpc 2.4.3-  GCLP_HBRBACKGROUND              = -10;- type   tagMENUBARINFO = record     cbSize: DWORD; ---------------------------------------------------------------------- dsiders · 2023-07-09 15:41 Quote from: lagprogramming on July 09, 2023, 04:30:07 pmBoth lcl/interfaces/win32/win32extra.pas and lcl/interfaces/customdrawn/customdrawn_winextra.pas files contain the following lines: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i { Win32 API constants not included in windows.pp }const  // Layout orientation  LAYOUT_RTL                        = $00000001; // Right to left  LAYOUT_BTT                        = $00000002; // Bottom to top  LAYOUT_VBH                        = $00000004; // Vertical before horizontal  LAYOUT_ORIENTATIONMASK            = (LAYOUT_RTL or LAYOUT_BTT or LAYOUT_VBH);  LAYOUT_BITMAPORIENTATIONPRESERVED = $00000008;  // not defined in fpc 2.4.3  GCLP_HBRBACKGROUND              = -10; The above constants have been included in FPC's rtl through the following commits: Oct 17, 2010 Commit 8304d2c1: * adds gwlp and gclp constants, mantis 17656 and 17655 https://gitlab.com/freepascal.org/fpc/source/- /commit/8304d2c1c5240cd8292b87ca2835bfb3f988d1fe Jul 06, 2013 Commit 609f6255: * added layout constants. https://gitlab.com/freepascal.org/fpc/source/- /commit/609f6255d4d371c993d8e231efc83ee97523d9bd This means that the constants declarations in the LCL have become obsolete 10 years ago. The ones in FPC's rtl should be enough. The following patch removes the declarations from the LCL. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i diff --git a/lcl/interfaces/customdrawn/customdrawn_winextra.pas b/lcl/interfaces/customdrawn/customdrawn_winextra.pasindex 1d7a36da24..d155284efe 100644--- a/lcl/interfaces/customdrawn/customdrawn_winextra.pas+++ b/lcl/interfaces/customdrawn/customdrawn_winextra.pas@@ -43,17 +43,6 @@ type     DisabledWindows: TList;   end; -{ Win32 API constants not included in windows.pp }-const-  // Layout orientation-  LAYOUT_RTL                      = $00000001; // Right to left-  LAYOUT_BTT                      = $00000002; // Bottom to top-  LAYOUT_VBH                      = $00000004; // Vertical before horizontal-  LAYOUT_ORIENTATIONMASK            = (LAYOUT_RTL or LAYOUT_BTT or LAYOUT_VBH);-  LAYOUT_BITMAPORIENTATIONPRESERVED = $00000008;-  // not defined in fpc 2.4.3-  GCLP_HBRBACKGROUND                = -10;- type   tagMENUBARINFO = record     cbSize: DWORD;diff --git a/lcl/interfaces/win32/win32extra.pas b/lcl/interfaces/win32/win32extra.pasindex 5997d81fe4..9d7bdc7787 100644--- a/lcl/interfaces/win32/win32extra.pas+++ b/lcl/interfaces/win32/win32extra.pas@@ -28,17 +28,6 @@ interface uses    Classes, LCLType, Windows, GraphType, SysUtils, ActiveX, ShlObj; -{ Win32 API constants not included in windows.pp }-const-  // Layout orientation-  LAYOUT_RTL                        = $00000001; // Right to left-  LAYOUT_BTT                        = $00000002; // Bottom to top-  LAYOUT_VBH                        = $00000004; // Vertical before horizontal-  LAYOUT_ORIENTATIONMASK            = (LAYOUT_RTL or LAYOUT_BTT or LAYOUT_VBH);-  LAYOUT_BITMAPORIENTATIONPRESERVED = $00000008;-  // not defined in fpc 2.4.3-  GCLP_HBRBACKGROUND              = -10;- type   tagMENUBARINFO = record     cbSize: DWORD;  You can't just remove them from LCL. The symbols in LCL need to be deprecated so the community has an opportunity to fix their code before it blows up. It doesn't matter how long ago they were introduced in RTL. This also does not address the scores of units in LCL that need to add wintypes to the uses clause and test whether win32extra is still needed. ---------------------------------------------------------------------- marcov · 2023-07-09 21:10 Quote from: dsiders on July 09, 2023, 05:41:57 pmYou can't just remove them from LCL. The symbols in LCL need to be deprecated so the community has an opportunity to fix their code before it blows up. It doesn't matter how long ago they were introduced in RTL. They have had 10 years, and haven't noticed there were two sets (that might switch on the USES clause order). In cases of low chances on trouble like this, I think this can be accelerated. The next major version of FPC will probably make even more obsolete, since then the moving of constants and other stuff to uitypes QuoteThis also does not address the scores of units in LCL that need to add wintypes to the uses clause and test whether win32extra is still needed. "Wintypes"?  Afaik we never supported that. Or do you uitypes? uitypes and other units from the same Delphi generation(s) are still being expanded, so probably wait till the next major FPC version (or the first point release after that) to do a big clean. ---------------------------------------------------------------------- dsiders · 2023-07-10 00:11 Quote from: marcov on July 09, 2023, 11:10:42 pmQuote from: dsiders on July 09, 2023, 05:41:57 pmYou can't just remove them from LCL. The symbols in LCL need to be deprecated so the community has an opportunity to fix their code before it blows up. It doesn't matter how long ago they were introduced in RTL. They have had 10 years, and haven't noticed there were two sets (that might switch on the USES clause order). In cases of low chances on trouble like this, I think this can be accelerated. The next major version of FPC will probably make even more obsolete, since then the moving of constants and other stuff to uitypes QuoteThis also does not address the scores of units in LCL that need to add wintypes to the uses clause and test whether win32extra is still needed. "Wintypes"?  Afaik we never supported that. Or do you uitypes? uitypes and other units from the same Delphi generation(s) are still being expanded, so probably wait till the next major FPC version (or the first point release after that) to do a big clean. Okay, wintypes was wrong. Doesn't change the fact that the symbols need to be deprecated in LCL before they are summarily yanked. In reality, the constants lag is on about should have been deprecated 10 years ago. But they were not. system.uitypes is another matter. LCL code has already deprecated those. Maybe someday, where there's a  dotted namespace unit in docs, they can actually be removed. ---------------------------------------------------------------------- marcov · 2023-07-10 08:22 This is a undocumented patch/hack unit for the lcl win32 interface writers benefit. Not end-user functionality(*). IMHO it is a bit over the top to insist on full cycle deprecation cycles just for the case somebody writes "win32extra.identifier" on a constant that is now in unit Windows in Delphi and Lazarus. (maybe even flag the whole unit as experimental or so that end users get a warning when they use it?) But if you insist I'll do it anyway, and compare all constants to trunk. The system.uitypes transition will be more profound, but it will also be a bigger relief when we are through that transition. The big advantages are however in FPC and other non LCL graphics and UI, where fcl-image now for the first time can use useful types like "TColor", for Lazarus it mostly is only pain. (*) and keep in mind that win32/64 users usually use latest and greatest release, while on Linux versions lag due to package systems for LTE releases not movign on ---------------------------------------------------------------------- dsiders · 2023-07-10 13:17 Quote from: marcov on July 10, 2023, 10:22:30 amThis is a undocumented patch/hack unit for the lcl win32 interface writers benefit. Not end- user functionality(*). IMHO it is a bit over the top to insist on full cycle deprecation cycles just for the case somebody writes "win32extra.identifier" on a constant that is now in unit Windows in Delphi and Lazarus. (maybe even flag the whole unit as experimental or so that end users get a warning when they use it?) But if you insist I'll do it anyway, and compare all constants to trunk. I'm not insisting that you do anything. I'm hoping that whoever picks up this code, and lobs it over another wall, decides to do the right thing and deprecates the symbols instead of deleting them. Quote from: marcov on July 10, 2023, 10:22:30 amThe system.uitypes transition will be more profound, but it will also be a bigger relief when we are through that transition. The big advantages are however in FPC and other non LCL graphics and UI, where fcl-image now for the first time can use useful types like "TColor", for Lazarus it mostly is only pain. (*) and keep in mind that win32/64 users usually use latest and greatest release, while on Linux versions lag due to package systems for LTE releases not movign on I'd be happy with having system.uitypes in rtl.chm. The code is in place, but the docs aren't. ---------------------------------------------------------------------- lagprogramming · 2023-07-11 07:55 Searching the lazarus directory for the mentioned constants shows that only LAYOUT_RTL is actively used, and it's used in just 2 files with a total of 3 occurrences: lazarus/lcl/interfaces/win32/win32callback.inc win32callback.inc (534,39) SetLayout(CurDoubleBuffer.DC, LAYOUT_RTL); lazarus/lcl/interfaces/win32/win32wsmenus.pp win32wsmenus.pp (814,21) SetLayout(AHDC, LAYOUT_RTL); win32wsmenus.pp (883,25) SetLayout(AHDC, LAYOUT_RTL); None of the other constants is actively used in the Lazarus sources. lcl/interfaces/win32/win32extra.pas already has the windows unit in uses, which means it will use the constants from FPC's rtl. lazarus/lcl/interfaces/win32/win32callback.inc is included in win32int.pp, which has the windows unit in uses. This means that it will use the constants from FPC's rtl. lcl/interfaces/win32/win32wsmenus.pp already has the windows unit in uses, which means it will use the constants from FPC's rtl. So I don't see a problem in applying the patch to the development Lazarus sources. I don't use Windows, but I had no problems in building Windows executables from Linux using Lazarus source files without those constants.