activex.pp definition problem lazarus / 67-Windows ---------------------------------------------------------------------- 440bx · 2025-07-07 21:30 Hello, In activex.pp there are a large number of GUID definitions that are supposed to be constant but, they are not. for instance, it is possible to do this: 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   GUID_NULL.D1            := 1;  IID_IEnumConnections.D1 := 1; Known GUIDs should not be changeable. ---------------------------------------------------------------------- Thaddy · 2025-07-08 04:54 Also the case in C++ btw... not a Pascal issue. I guess you can declare these GUIDS as typed const, but in {$J-} state which makes them immutable. I thought you knew that: 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 {$push}{$J-}const  myguid:TGUid = '{77DE903C-1453-4622-93A0-1C46B74627B9}';{$pop}begin  myguid.d1 := 5;  // Error: Can't assign values to const variable.end.It should be fine to compile the whole interface section of the activex unit in forced {$J-} state. (If that is not already the case) The guid ends up in .rodata and so is immutable:Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i .section .rodata.n_TC_$P$PROGRAM_$$_MYGUID,"aw"        .balign 4.globl  TC_$P$PROGRAM_$$_MYGUIDTC_$P$PROGRAM_$$_MYGUID:        .long   2011074620        .short  5203,17954        .byte   147,160,28,70,183,70,39,185  # same guid, but in decimal.# End asmlist al_rotypedconstsMaybe @Marcov can check if this is the case and otherwise protect the interface section with {$J-} ? This should not otherwise affect the code. Must be done with {$push}/{$pop}, though. ---------------------------------------------------------------------- 440bx · 2025-07-08 05:54 Quote from: Thaddy on July 08, 2025, 06:54:30 amI thought you knew that: You actually thought ?... I hope you didn't experience too much pain. ---------------------------------------------------------------------- Thaddy · 2025-07-08 06:04 Nah... Hope its solves the problem, though. I did: - around line 101 {$PUSH}{$WRITEABLECONST OFF} // start of GUID consts - around line 189 {$POP} // end of GUID consts, alternatively around line 4954 for the pop. Just above implementation. That seems enough. Not really good with patching with GIT yet. push/pop is necessary to avoid settings spill. 101/189 seems the most "correct": least code affected. I will leave that up to Marcov. Just in case: 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 packages/winunits-base/src/activex.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/winunits- base/src/activex.pp b/packages/winunits-base/src/activex.ppindex 56dec102fe..2420a7e5bc 100644--- a/packages/winunits- base/src/activex.pp+++ b/packages/winunits-base/src/activex.pp@@ -98,7 +98,7 @@    TOleColor           = OLE_COLOR;    POleColor           = LPOle_Color;    HHandle             = UINT_PTR;-+{$PUSH}{$WRITABLECONST OFF} CONST    GUID_NULL  : TGUID =  '{00000000-0000-0000-0000-000000000000}';    IID_IPrint : TGUID = '{B722BCC9-4E68-101B-A2BC-00AA00404770}';@@ -186,7 +186,7 @@    IID_IOleCache2 : TGUID = '{00000128-0000-0000-C000-000000000046}';    IID_IOleCacheControl : TGUID = '{00000129-0000-0000-C000-000000000046}';    IID_IOleItemContainer : TGUID = '{0000011C-0000-0000-C000-000000000046}';-+{$POP}       // bit flags for IExternalConnection CONST Should be close to a correct patch. (against trunk from today 10:00) ---------------------------------------------------------------------- nanobit · 2025-07-09 17:19 Unfortunately {$J+} is default in FPC, whereas Delphi has the preferable default {$J-} since Delphi 6. ---------------------------------------------------------------------- Thaddy · 2025-07-09 19:05 See the bug report..... And your statement about Delphi is not true D7 behaves the same, D12.1 behaves the same. ---------------------------------------------------------------------- nanobit · 2025-07-09 19:37 Excerpt from Delphi 6 Developer’s Guide (Steve Teixeira): QuoteMigrating from Delphi 5: Although compatibility between Delphi 5 and 6 is quite good, there are a few minor issues you should be aware of as you make the move. Writable Typed Constants The default state of the $J compiler switch (also known as $WRITEABLECONST) is now OFF, where it was ON in previous versions. This means that attempts to assign to typed constants will raise a compiler error unless you explicitly enable this behavior using $J+. ---------------------------------------------------------------------- gues1 · 2025-07-09 20:27 In "Delphi 7 Object Pascal Language Guide" at page 5-43: QuoteIn the default {$J-} compiler state, typed constants can not have new values assigned to them; they are, in effect, read-only variables. ---------------------------------------------------------------------- Thaddy · 2025-07-10 11:03 Yes. Hence my patch.