Is there some pragma to relax it in TP/Delphi modes too?
No, there's not. Also FPC does not have “pragmas” they are called “directives”.
That's a miss.
OTOH, should such rigorous a check be kept even in TP/Delphi mode today?
From language consistency point, it is harmful now, that generic types are in both Delphi and FPC. It makes the same in essence entities have different behavior.
From compatibiltiy point - let FPC "import" code from TP/Delphi and compile it immediately with no (or at least minimum) adaptations - it adds nothing.
It also, like nay other special case, adds to compiler complexity and mantainance burden.
Frankly, i believe this level of purity is obsolted long ago. It made sense for 1970-s J&W Pascal (only had static arrays, which immediately proved a problem for procedure calls already in USCD) and the purposes of it: no practical programming, education only, force good habits into students, and cutting corners they would learn on their own. But when application programming became largely selecting and combinating ready libraries - it only became a source of inconsistencies in Delphi. TStringDynArray vs TBytes vs many ad hoc types, etc. Implementing this restriction feels today like showing off "look, how closely we can emulate TP/D"-----------------
"directive" is rather ambiguous a word. "stdcall" or "virtual" after procedure declaration are directives too, and many more examples. A specially formatted comment that changes compiler behavior though is a rather specific sense, immediately evident to anyone reading the "pragma" term, which is much shorter than "compiler directive" of J&W.
---------------
Now, coming back to writeable constants...
D:\fpcupdeluxe\lazarus\lcl\widgetset\wsstdctrls.pp
procedure RegisterToggleBox;
const
Done: Boolean = False;
begin
if Done then exit;
WSRegisterToggleBox;
// if not WSRegisterToggleBox then
// RegisterWSComponent(TToggleBox, TWSToggleBox);
Done := True;
end;
If to pursue structural programming ideals, those should be re-written to class vars or to unit's local global vars, but unless someone does it - LCL design is dependent upon having $J+ mode. I think no one would bother to fix it though. And LCL remain laden with this horrorific concept forever, despite all the forum anger :-)